表单叶面
<script language="javascript" src="include/selectoption.js"></script>

<select name="privceid" id="privceid" onchange="editnextselect(this,'cityid');">
<option value="-1">请选择</option>
</select>省
<select name="cityid" id="cityid" onchange="editnextselect(this,'county');">
<option value="-1">请选择</option>
</select>市
<select name="county" id="county">
<option value="-1">请选择</option>
</select>区/县

<script language="javascript">
var privceid = "<%=privceid%>";
var cityid = "<%=cityid%>";
var county = "<%=county%>";
getdatelist('&pid=',privceid,'privceid');
if(cityid != ""){getdatelist('&pid='+ privceid ,cityid,'cityid');}
if(county != ""){getdatelist('&pid=' + cityid ,county,'county');}
function editnextselect(obj,nexselid){
if(nexselid == 'cityid'){
selvalue = cityid;
}else{
selvalue = county;
}
var pid = obj.options[obj.selectedIndex].value;
if(pid != null){
getdatelist('&pid='+ pid ,selvalue,nexselid);
}
}
</script>
js包含叶面
// JavaScript Document
function InitAjax(){
var ajax = false;
try{ajax = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e){
try { ajax = new ActiveXObject("Microsoft.XMLHTTP");}
catch (E) { ajax = false; }
}
if (!ajax && typeof XMLHttpRequest!='undefined') {ajax = new XMLHttpRequest();}
return ajax;
}
function datexml(url,value){
var number = Math.random();
var url = url +"?qaaq=" + number + value;
var ajax = InitAjax();
ajax.open("GET", url, false);
ajax.send(null);
//ajax.onreadystatechange = function() { }
if(ajax.readyState == 4 && ajax.status == 200){return ajax.responseText;}
}
function getdatelist(values,selvalues,SelectName){
var getdate = datexml("include/xmlgetp_c_c.asp", values);
if(getdate){
if(getdate != "wrong" && getdate !="no"){
var objSelect = document.getElementById(SelectName);
objSelect.options.length=1;
var datearray = getdate.split("$");
for(i=0;i<datearray.length-1;i++) {
var op = window.document.createElement("option");
op.value = datearray[i].split("|")[0];
op.innerHTML = unescape(datearray[i].split("|")[1]);
objSelect.appendChild(op);
}
if(selvalues != ""){
for (i=0;i<objSelect.options.length;i++){
if (objSelect.options[i].value == selvalues){
objSelect.options[i].selected = true;
break;
}
}
}
}
}
}
读取数据库叶面
<!--#include file="dbconn.asp"-->
<%
pid=request.querystring("pid")
if pid<>"" then
if isnumeric(pid)=false then
response.write "wrong"
end if
end if
if pid="" then
sql = " select zipcode,zipname from ZIPCODEINFO where parentzip is null "
else
sql = " select zipcode,zipname from zipcodeinfo where parentzip = '"& pid &"'"
end if
call dbopen
set rs=conn.execute(sql)
if not rs.eof then
do while not rs.eof
response.write rs("zipcode")&"|"&escape(rs("zipname"))&"$"
rs.movenext
loop
else
response.write "no"
end if
set rs=nothing
call dbclose
%>





































































































