<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>

<body>
    
<script>    
function ajax_change(str){
 $.ajax({
        type: 'POST',
        url: 'ajax.php',
        data: {class: str},
        success: function (data) {            
           $("#checkName").html(data);
        },
        error: function (xhr) {
           //Do Something to handle error
           alert("some error found");
        }
    });
 }
</script>
    
<?php 
error_reporting(0);	    
$con = @mysqli_connect("localhost", "root", "abc456", "ProudAsiaDB") 
					   or die(mysqli_connect_error());
mysqli_query($con,"set names utf8"); 
$sql = "select C_NAME FROM cust001 ORDER BY C_NAME ASC";
$query = mysqli_query($con,$sql);
while($result = mysqli_fetch_array($query)){
     if($strDefault == $result["C_NAME"]){$sel = "selected";}
     else{$sel = "";}
}
?>  
    
<select class="form-control" name="class" id="class" onchange="" value="--">
    <option><?php echo $result["C_NAME"]; ?></option>
</select>
<input type="text" class="form-control" name="name" id="name" 
       list="checkName" autocomplete="off" required>
<datalist id="checkName">
    <?php
        $sql_siswa = "SELECT * from cust001";
        $result = $conn->query($sql_siswa);
        if ($result->num_rows > 0) {
            while($row = $result->fetch_assoc()){
                echo "<option value=\"".$row["C_NAME"]."\">";
            }
        }
    ?>
</datalist>   
</body>
</html>