两级联动菜单
----------------------------------------------------------------------------------------------
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<HTML>
<HEAD>
<TITLE>NewDocument</TITLE>
<METANAME="Generator"CONTENT="EditPlus">
<METANAME="Author"CONTENT="">
<METANAME="Keywords"CONTENT="">
<METANAME="Description"CONTENT="">
<scriptlanguage="JavaScript"type="text/javascript">
<!--
varprovince_ar=newArray("","学历文凭|旅游管理,工商企业管理,文秘,金融,国际贸易,会计,英语,计算机应用,法律,艺术设计","成人高教|工商企业管理,国际经济与贸易,外贸英语,计算机应用与管理,艺术设计","高教自考|饭店管理,工商企业管理,中英合作商务管理,保险,国际贸易,英语,电子商务,计算机及应用,法律,广告");
functionshow_province()
{
varpro_tmp=document.all.province;
for(m=pro_tmp.options.length-1;m>0;m--)
pro_tmp.options[m]=null;
for(i=0;i<province_ar.length;i++)
{
if(province_ar[i]!="")
{
tmp=province_ar[i].split("|");
pro_tmp.options[i]=newOption(tmp[0],tmp[0]);
}
}
}
functionshow_city(sc)
{
vartemp=document.all.city;
for(m=temp.options.length-1;m>0;m--)
temp.options[m]=null;
if(province_ar[sc]!="")
{
tmp=province_ar[sc].split("|");
tmp=tmp[1];
tmp=tmp.split(",");
for(i=0;i<tmp.length;i++)
{
temp.options[i]=newOption(tmp[i],tmp[i]);
}
}
}
setTimeout("show_province();",20);//第一个搜索中省份城市对应
-->
</script>
</HEAD>
<BODY>
<FORMname="testform"id="testform">
<selectid=province
οnchange=show_city(this.options.selectedIndex)>
<OPTIONvalue=""selected>请选择类别</option>
</select>
<selectid=city>
<OPTIONvalue=""selected>请选择专业</OPTION>
</select>
</FORM>
</BODY>
</HTML>
----------------------------------------------------------------------------------------------
多级联动菜单
----------------------------------------------------------------------------------------------
<BODY>
<SELECTNAME="s1"><option>需要JavaScript才能正确显示</SELECT>
<SELECTNAME="s2"></SELECT>
<SELECTNAME="s3"></SELECT>
<SELECTNAME="s4"></SELECT>
<SCRIPTLANGUAGE="JavaScript">
<!--
//选择框的名字
selector=["s1","s2","s3","s4"];
//选择项:"名字","值",子选择
menu=[
"地球","1",
[
"中国","86",
[
"北京","BJ",
[
"--","1",null
],
"四川","SC",
[
"成都","28",null,
"乐山","",null,
"攀枝花","",null,
"自贡","",null,
"德阳","",null,
"绵阳","",null
]
],
"米国","1",
[
"加利福尼亚","CA",
[
"旧金山","1",null,
"洛杉矶","2",null
],
"华盛顿","WA",
[
"西雅图","seattle",null
]
]
],
"火星","2",
[
"大峡谷","86",
[
"小山丘","BJ",
[
"A地区","28",null,
"B地区","",null,
"C地区","",null
]
]
]
];
functionwizz(level)
{
if(level==0)
a=menu;
else
{
str="menu";
for(i=0;i<level;i++)
str+="["+(document.all[selector[i]].selectedIndex*3+2)+"]";
a=eval(str);
}
if(a==null)return;
s=document.all[selector[level]];
i=s.length;
while(i>0)s.options[--i]=null;
while(i<Math.floor(a.length/3))
s.options[i]=Option(a[i*3],a[i++*3+1]);
s.οnchange=Function("wizz("+(level+1)+")");
wizz(level+1);
}
wizz(0);
//-->
</SCRIPT>
</BODY>
</HTML>
----------------------------------------------------------------------------------------------