subcat[0] = new Array("主页浏览","3","1"); subcat[1] = new Array("书签工具","3","5"); subcat[2] = new Array("FTP 工具","1","12"); subcat[3] = new Array("系统增强","2","13"); subcat[4] = new Array("系统设置","2","14"); subcat[5] = new Array("系统备份","2","15"); subcat[6] = new Array("桌面工具","2","16"); subcat[7] = new Array("压缩解压","3","21"); subcat[8] = new Array("文件管理","3","22"); subcat[9] = new Array("文件更名","3","24"); subcat[10] = new Array("电子阅读","3","27"); subcat[11] = new Array("媒体播放","6","42"); subcat[12] = new Array("音频处理","6","43"); subcat[13] = new Array("下载工具","1","60"); subcat[14] = new Array("系统安全","10","61"); subcat[15] = new Array("网吧管理","10","63"); subcat[16] = new Array("网络安全","10","64"); subcat[17] = new Array("教育管理","11","66"); subcat[18] = new Array("邮件工具","1","72"); onecount=19; changelocation(1);function changelocation(locationid) { document.myform.subcateid.length = 0; var locationid=locationid; var i; for (i=0;i < onecount; i++) { if (subcat[i][1] == locationid) { document.myform.subcateid.options[document.myform.subcateid.length] = new Option(subcat[i][0], subcat[i][2]); } }
<!--
var where = new Array(10);
function comefrom(loca,locacity) { this.loca = loca; this.locacity = locacity; }
where[0]= new comefrom("请选择省份名","请选择城市名");
where[1] = new comefrom("北京","|东城|西城|崇文|宣武|朝阳|丰台|石景山|海淀|门头沟|房山|通州|顺义|昌平|大兴|平谷|怀柔|密云|延庆");
where[2] = new comefrom("上海","|黄浦|卢湾|徐汇|长宁|静安|普陀|闸北|虹口|杨浦|闵行|宝山|嘉定|浦东|金山|松江|青浦|南汇|奉贤|崇明");
where[3] = new comefrom("天津","|和平|东丽|河东|西青|河西|津南|南开|北辰|河北|武清|红挢|塘沽|汉沽|大港|宁河|静海|宝坻|蓟县");
where[4] = new comefrom("重庆","|万州|涪陵|渝中|大渡口|江北|沙坪坝|九龙坡|南岸|北碚|万盛|双挢|渝北|巴南|黔江|长寿|綦江|潼南|铜梁|大足|荣昌|壁山|梁平|城口|丰都|垫江|武隆|忠县|开县|云阳|奉节|巫山|巫溪|石柱|秀山|酉阳|彭水|江津|合川|永川|南川");
where[5] = new comefrom("河北","|石家庄|邯郸|邢台|保定|张家口|承德|廊坊|唐山|秦皇岛|沧州|衡水");
where[6] = new comefrom("山西","|太原|大同|阳泉|长治|晋城|朔州|吕梁|忻州|晋中|临汾|运城");
where[7] = new comefrom("内蒙古","|呼和浩特|包头|乌海|赤峰|呼伦贝尔盟|阿拉善盟|哲里木盟|兴安盟|乌兰察布盟|锡林郭勒盟|巴彦淖尔盟|伊克昭盟");
where[8] = new comefrom("辽宁","|沈阳|大连|鞍山|抚顺|本溪|丹东|锦州|营口|阜新|辽阳|盘锦|铁岭|朝阳|葫芦岛");
where[9] = new comefrom("吉林","|长春|吉林|四平|辽源|通化|白山|松原|白城|延边");
where[10] = new comefrom("黑龙江","|哈尔滨|齐齐哈尔|牡丹江|佳木斯|大庆|绥化|鹤岗|鸡西|黑河|双鸭山|伊春|七台河|大兴安岭"); function select() {
with(document.creator.province) { var loca2 = options[selectedIndex].value; }
for(i = 0;i < where.length;i ++) {
if (where[i].loca == loca2) {
loca3 = (where[i].locacity).split("|");
for(j = 0;j < loca3.length;j++) { with(document.creator.city) { length = loca3.length; options[j].text = loca3[j]; options[j].value = loca3[j]; var loca4=options[selectedIndex].value;}}
break;
}}
document.creator.newlocation.value=loca2+loca4;
}
function init() {
with(document.creator.province) {
length = where.length;
for(k=0;k<where.length;k++) { options[k].text = where[k].loca; options[k].value = where[k].loca; }
options[selectedIndex].text = where[0].loca; options[selectedIndex].value = where[0].loca;
}
with(document.creator.city) {
loca3 = (where[0].locacity).split("|");
length = loca3.length;
for(l=0;l<length;l++) { options[l].text = loca3[l]; options[l].value = loca3[l]; }
options[selectedIndex].text = loca3[0]; options[selectedIndex].value = loca3[0];
}}
-->
</script>
<body onload="init()">
<font color=#000000><b>来自:</b><br>请输入您所在国家的具体地方。此项可选<br><br>
省份 <select name="province" onChange = "select()"></select> 城市 <select name="city" onChange = "select()"></select><br>
我在 <input type=text name="newlocation" maxlength=12 size=12 style="font-weight: bold"> 不能超过12个字符(6个汉字)
</form>
dim conn
dim connstr
on error resume next
connstr="DBQ="+server.MapPath("test.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.CreateObject("ADODB.CONNECTION")
conn.open connstr
%><script language = "JavaScript">
sall=new Array();
<%
Dim i
i=0
set rs=conn.execute("select * from subject")
do while not rs.eof
%>
sall[<%=i%>]=new Array("<%=rs("subjectname")%>","<%=rs("departid")%>","<%=rs("subjectid")%>");
<%
i=i+1
rs.movenext
loop
rs.close
%>
function changeselect(selvalue)
{
document.myform.Nclassid.length=0;
var selvalue=selvalue;
var i;
for(i=0;i<sall.length;i++)
{
if(sall[i][1]==selvalue)
{
var newOption1=new Option(sall[i][0],sall[i][2]);
document.all.Nclassid.add(newOption1);
}
}
}
</script>
<form method="post" name="myform" action="ru_query.asp">
<select name="classid" onChange="changeselect(document.myform.classid.options[document.myform.classid.selectedIndex].value)" size="1">
<option selected value="">未指定条件</option>
<%
set rs1=conn.execute("select * from depart")
do while not rs1.eof
response.write "<option value='"&rs1("departid")&"'>"&rs1("departname")&"</option>"&chr(13)+chr(10)
rs1.movenext
loop
rs1.close
%>
</select>
<select name="Nclassid">
<option selected value="">未指定</option>
</select> 数据库设计表depart
字段
departID 自动编号
departName 文本 '省份表subject
字段
subjectID 自动编号
subjectName 文本 '城市
departID 数字 '所属国家ID
<html>
<head>
<title>级联下拉菜单</title>
</head>
<body onload="changelocation(document.myform.cateid.options[document.myform.cateid.selectedIndex].value)">
<form name="myform" method="post" action="Publish.asp" target="_top">
<select name="cateid" onChange="changelocation(document.myform.cateid.options[document.myform.cateid.selectedIndex].value)" size="1">
<option selected value='1' name=cateid>网络软件</option><option value='2' name=cateid>系统工具</option><option value='3' name=cateid>应用软件</option><option value='6' name=cateid>多媒体类</option><option value='10' name=cateid>安全相关</option><option value='11' name=cateid>教育教学</option>
</select>
<br>
<select name="subcateid" size="1">
</select>
<SCRIPT language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
subcat[0] = new Array("主页浏览","3","1");
subcat[1] = new Array("书签工具","3","5");
subcat[2] = new Array("FTP 工具","1","12");
subcat[3] = new Array("系统增强","2","13");
subcat[4] = new Array("系统设置","2","14");
subcat[5] = new Array("系统备份","2","15");
subcat[6] = new Array("桌面工具","2","16");
subcat[7] = new Array("压缩解压","3","21");
subcat[8] = new Array("文件管理","3","22");
subcat[9] = new Array("文件更名","3","24");
subcat[10] = new Array("电子阅读","3","27");
subcat[11] = new Array("媒体播放","6","42");
subcat[12] = new Array("音频处理","6","43");
subcat[13] = new Array("下载工具","1","60");
subcat[14] = new Array("系统安全","10","61");
subcat[15] = new Array("网吧管理","10","63");
subcat[16] = new Array("网络安全","10","64");
subcat[17] = new Array("教育管理","11","66");
subcat[18] = new Array("邮件工具","1","72");
onecount=19;
changelocation(1);function changelocation(locationid)
{
document.myform.subcateid.length = 0; var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.subcateid.options[document.myform.subcateid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</SCRIPT>
</form>
</body>
</html>