52,797
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<script language="text/javascript">
var xmlhttp=null;
//如果自己写,就要考虑 FireFox 或是 IE 了,
if(windo.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
xmlhttp.overrideMimeType('text/sml');
}else if(window.ActiveXObject){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
//发个数据到服务端
function sendInfor(){
var getID=document.getElementById("select_city").value;
var url="ajax.php?CityID="+getID;
xmlhttp.open("GET",url,true);
xnlhttp.onreadystatechange=getTowns;
xmlhttp.send(null);
}
//接受数据
function getInfor(){
if(xmlhttp.readyState==4&&xmlhttp.status==200){
document.getElementById("select_town").innerHTML="<select>"+xmlhttp.responseText+"</select>"
}
}
</script>
</head>
<body>
<div id="select_city">
<select onchange="sendInfor()">
<option value="1">China</option>
<option value="2">Japan</option>
</select>
</div>
<div id="select_town">
null
</div>
</body>
</html>
<?php
include "conn.php";
CityID=&_POST["CityID"];
$sql="select * from CityID";
$recordsets = $conn->Execute($sql);
while($row=$recordsets->FetchRow()){
echo "<option>".$row("TownName")."</option>"
}
?>