<SCRIPT type="text/javascript">
var XMLHttp;
function createXmlhttpRequest() {//判断浏览器 创建异步请求对象
if (window.ActiveXObject) {//IE
XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {//火狐
XMLHttp = new XMLHttpRequest;
}
}
function getshibysheng() {
var shengname = document.getElementById("province").value;
createXmlhttpRequest();
var url = "city!getcitylist.action";
var arg = "province=" +shengname+"&time="+ new Date().getTime();
XMLHttp.onreadystatechange = getshi1;
XMLHttp.open("POST", url);
XMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
XMLHttp.send(arg);
}
function getshi1(){
if(XMLHttp.readyState==4&&XMLHttp.status==200){
var allshi = JSON.parse(XMLHttp.responseText);
document.all.city.length=0;
for(var i =0;i<allshi.length;i++)
{
var option =document.createElement("OPTION");
option.text=allshi[i].name;
option.value=allshi[i].id;
option.id=allshi[i].pid;
document.all.city.options.add(option);
}
if(document.all.province.value=="quanguo"){
var option =document.createElement("OPTION");
option.text="-请选择地区-";
document.all.city.options.add(option);
}
}
}
</SCRIPT>