我想创建一个动态下拉列表 选择DE时显示SDE 我的问题是虽然显示了DE列表(快照附加) 但我没有得到SDE (因为我认为我无法传递onclick值 代码中的以下行:--------- 回声'。$ jto。'';)
我尝试了很多选项,但没有选择
enter code here
<form name="form1" action="" method="post">
<table>
<tr>
<td> select de</td>
<td><select id="dedd" onChange="change_de()">
<option>select</option>
<?php
$jtosql="SELECT DISTINCT DE_OD FROM cdr_phone_control";
$jtoqr=odbc_exec($conn, $jtosql);
while(odbc_fetch_row($jtoqr))
{
$jto=odbc_result($jtoqr,"DE_OD");
echo '<option value="'.$jto.'">'.$jto.'</option>';
//echo "<option>".$jto."</option>";
/*?><option value="<?php echo $jto; ?>">"<?php".$jto."?></option><?php
?><option><?php echo ."$jto." ?></option><?php
?><option value="<?php echo $jto ?>"><?php echo "$jto"; ?></option><?php
?><a href="test52.php?page=<?php echo $b;?>" style="text-decoration:none"><input type="submit" value="<?php echo $b." "; ?>"</a><?php*/
}
$page=$_GET["dedd"];
ECHO $jto;
echo $jtoqr;
echo $page;
/*?><a href="test52.php?page=<?php echo $b;?>" style="text-decoration:none"><input type="submit" value="<?php echo $b." "; ?>"</a><?php*/
?>
</select>
</td></tr>
<tr><td>select sde</td>
<td>
<div id="sde">
<select><option>select</option></select></div>
</td></tr>
</table>
</form>
<script type="text/javascript">
function change_de()
{
var xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","ajax.php?de="+document.getElementById("dedd").value,false);
xmlhttp.send(null);
//alert(xmlhttp.responseText);
document.getElementById("sde").innerHTML=xmlhttp.responseText;
}
</script>
/*AJAX.PHP STARTS HERE */
$de=$_GET['dedd'];
//$staff=$_POST['callLL'];
if($de!="")
{
$jtosql="SELECT DISTINCT SDO_OD FROM cdr_phone_control where de_od='$de'";
$jtoqr=odbc_exec($conn, $jtosql);
echo "<select>";
while(odbc_fetch_row($jtoqr))
{
$jto=odbc_result($jtoqr,"SDO_OD");
//echo "<option>".$jto."</option>";
/*?><option value="<?php echo $jto; ?>">"<?php".$jto."?></option><?php
?><option><?php echo ."$jto." ?></option><?php*/
?><option value="<?php echo $jto ?>"><?php echo "$jto"; ?></option><?php
}
echo "</select>";
[enter image description here][1]
[1]: https://i.stack.imgur.com/S37R8.jpg