我有下一个脚本:
test.php - 在标题中我有:
<script>
function dest(str2) {
if (str2 == "") {
return;
} else {
//alert(str2);
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("destin").innerHTML = xmlhttp.responseText;
alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET","dest.php?q2="+str2,true);
xmlhttp.send();
}
}
</script>
test.php - 我体内有:
<div class="col-sm-12">
<div class="form-group has-icon has-label selectpicker-wrapper">
<label>De la</label>
<?php
$plecari=db_query("SELECT DISTINCT plecare from `pl_dest_pf` WHERE activ = 'activ' ORDER BY plecare");
?>
<select class="selectpicker input-price" data-live-search="true" data-width="100%" data-toggle="tooltip" title="Select" name="plecare" id="dela" onchange="dest(this.value)">
<?php
while($rez_plecari = $plecari->fetch_assoc()){
?>
<option value="<?php echo $rez_plecari['plecare']?>"><?php echo $rez_plecari['plecare']?></option>
<?php } ?>
</select>
<span class="form-control-icon"><i class="fa fa-location-arrow"></i></span>
</div>
</div>
<div class="col-sm-12">
<div class="form-group has-icon has-label selectpicker-wrapper">
<label>Pana la </label>
<select id="destin" class="selectpicker input-price" data-live-search="true" data-width="100%" data-toggle="tooltip" title="Select" name="desti">
</select>
<span class="form-control-icon"><i class="fa fa-location-arrow"></i></span>
</div>
</div>
dest.php:
<?php
session_start();
include('include/functions2.php');
$a=$_GET['q2'];
$destinatie=db_query("SELECT DISTINCT destinatie from `pl_dest_pf` WHERE plecare ='".$a."' AND activ = 'activ' ORDER BY destinatie ");
?>
<option value="">Selecteaza...</option>
<?php
while($rez_destinatie = $destinatie->fetch_assoc()){
?>
<option value="<?php echo $rez_destinatie['destinatie']?>"><?php echo $rez_destinatie['destinatie']?></option>
<?php } ?>
我的问题是返回第二个选择的值,但是在第二个选择时没有显示(我只能通过alert命令看到它)。 拜托,我可以告诉我哪里有错误。 非常感谢!