1 回答

TA貢獻1836條經驗 獲得超3個贊
<?php
<?php
/*getcustomer.php*/
include('config.php');
$sql = "select * from promotor";
$result = mysqli_query($conn, $sql);
?>
<select id="user">
<option value="">Select Country</option>
<?php
if(mysqli_num_rows($result)){
while($row = mysqli_fetch_assoc($result)){
echo '<option value="'.$row['Promotor_ID'].'">'.$row['Promotor_Name'].'</option>';
}
}else{
echo '<option value="">User Not Available</option>';
}
?>
</select>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
function showCustomer(str) {
var xhttp;
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
}
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("txtHint").innerHTML = this.responseText;
}
};
xhttp.open("GET", "getcustomer.php?q="+str, true);
xhttp.send();
}
</script>
<select id="role" name="role" class="form-control" onchange="showCustomer(this.value)">
<option value="default">Select Role</option>
<option value="NPA">NPA</option>
<option value="BDA">BDA</option>
</select>
<div id="txtHint">User list will be here</div>
- 1 回答
- 0 關注
- 116 瀏覽
添加回答
舉報