Index.asp
Program code:
<title></title>
<meta content= "text/html; charset=gb2312 "http-equiv=" Content-type ">
<style type= "Text/css" ><!--
FONT{FONT-SIZE:12PX}
TD{FONT-SIZE:12PX}
A{color: #333399}
A:hover{color: #FF6600}
--></style>
<script language= "JavaScript" type= "Text/javascript" ><!--
function Funonload () {
Document.all.list_file.src= "jscript_city.asp?base=0&sele=0-&elem=select01";
}
PBase series, to 0 base,
Psele is the value of <option
Pele is the next level of the form name
function Chgselect (Pbase,psele,pelem) {
When a list is changed. Clears the values of future lists.
For (I=parseint (Pelem.replace ("select", "")); i<=5;i++) {
var tmp= "+i";
var pelem1=eval ("document.") Form1.select "+tmp.substr (tmp.length-2));
pelem1.length=1;
pelem1.selectedindex=0;
}
JS use ASP to get database data to update the subordinate list
Document.all.list_file.src= "jscript_city.asp?base=" +pbase+ "&sele=" +psele+ "&elem=" +pElem;
}
--></script>
<script id= "List_file" language= "JavaScript" type= "Text/javascript" "src=" "></script>
<body bgcolor= "#FFFFFF" leftmargin= "0" topmargin= "2" text= "#333333" >
<form name= "Form1" >
<select name= "Select01" >
<option value= "" > Province ...</option>
</select>
<select name= "Select02" >
<option value= "" > City ...</option>
</select>
<select name= "Select03" >
<option value= "" > County ...</option>
</select>
<select name= "Select04" >
<option value= "" > Xiang ...</option>
</select>
<select name= "Select05" >
<option value= "" > Village ...</option>
</select>
</form>
</body>
' Jscript_city.asp
Program code:
<%
' Varbase drop down menu level
' Varsele the database ID of the Drop-down menu item selected
' Varelem the name of the form next level
Varbase=request.querystring ("base")
Varsele=left (Request.QueryString ("Sele"), InStr (Request.QueryString ("Sele"), "-"-1)
Varelem=request.querystring ("Elem")
Vardistname= ""
Varautoid= ""
Set condb=server.createobject ("ADODB. CONNECTION ")
Condb.open "Driver={microsoft Access Driver (*.mdb)};D bq=" &server.mappath ("Db1.mdb")
Sqlcommand= "SELECT * FROM table1 where filed1=" &varBase& "and filed2=" &varsele
Set Rsrecord=condb.execute (SqlCommand)
While not rsrecord.eof
VARDISTNAME=VARDISTNAME&CHR (&rsrecord) ("Filed3") &CHR (34)
VARAUTOID=VARAUTOID&CHR (&rsrecord) ("id") &CHR (34)
Rsrecord.movenext
If not rsrecord.eof Then
vardistname=vardistname& ","
varautoid=varautoid& ","
End If
Wend
Response.Write ("var vardistname=new Array (" &varDistName& ")" &vbcrlf)
Response.Write ("var varautoid=new Array (" &varAutoID& ")" &vbcrlf)
Response.Write ("var varelem=eval" &CHR (&) document. Form1. " &VARELEM&CHR (& ")" &vbcrlf)
Response.Write ("varelem.length=vardistname.length+1;") &VBCRLF)
Response.Write ("for (Var i=0;i<vardistname.length;i++) {" &vbcrlf)
Response.Write ("Varelem.options[i+1].text=vardistname;") &VBCRLF)
Response.Write ("varelem.options[i+1].value=varautoid+ '-' +vardistname;") &VBCRLF)
Response.Write ("}" &vbcrlf)
Response.Write ("varelem.selectedindex=0;") &VBCRLF)
%>
Db1.mdb
'-------------------------------------------------
Si Yellow CuO zeng CuO an Eucalyptus cun, Xiamen, Fujian
Fengze, Quanzhou, Fujian, West Lake Head Village
For example, the above level five is converted into a database:
'-------------------------------
ID filed1 filed2 FILED3
1 0 0 Fujian
2 1 1 Xiamen
3 1 1 Quanzhou
4 2 2 Siming
5 3 4 Yellow CuO
6 4 5 Zeng CuO Eucalyptus village
7 2 3 Fengze
8 3 7 West Lake
9 4 8 Head Village
'-------------------------------------------------
Database Description:
ID Auto Number
Filed1 the rank of the Drop-down menu list (see series. You can set its precision. is a numeric type)
FILED2 First level ID number (with long integer bar)
Filed3 This is needless to say (file. The length of the view itself)
This procedure is passed under the iis4+win2000p+access2000.