二级条件联动菜单

<div id="tar"></div>
<SCRIPT LANGUAGE="JavaScript" DEFER>
var fMenu = ["请选择大类","产业技术开发","高新技术产业化","引进消化吸收再创新","产学研联合开发","企业信息化","可持续发展"]
var fValue = ["","产业技术开发","高新技术产业化","引进消化吸收再创新","产学研联合开发","企业信息化","可持续发展"]
var sMenu = [["请选择小类"],["机械","电子","轻工","纺织","医药","冶金","化工","建材","汽车","其他"],["电子信息产业","生物技术和现代医药产业","光机电一体化产业","新能源产业","新材料产业","环保产业"],["机械","电子","轻工","纺织","医药","冶金","化工","建材","汽车","其他"],["机械","电子","轻工","纺织","医药","冶金","化工","建材","汽车","其他"],["机械","电子","轻工","纺织","医药","冶金","化工","建材","汽车","其他"],["机械","电子","轻工","纺织","医药","冶金","化工","建材","汽车","其他"]]
var sValue = [[""],["机械","电子","轻工","纺织","医药","冶金","化工","建材","汽车","其他"],["电子信息产业","生物技术和现代医药产业","光机电一体化产业","新能源产业","新材料产业","环保产业"],["机械","电子","轻工","纺织","医药","冶金","化工","建材","汽车","其他"],["机械","电子","轻工","纺织","医药","冶金","化工","建材","汽车","其他"],["机械","电子","轻工","纺织","医药","冶金","化工","建材","汽车","其他"],["机械","电子","轻工","纺织","医药","冶金","化工","建材","汽车","其他"]]

var oWhere = document.all.tar;
var ofMenu = document.createElement("<SELECT name='zxlb'>");
var osMenu = document.createElement("<SELECT name='zxlb1'>");
with(oWhere)appendChild(ofMenu),appendChild(osMenu);

createMainOptions();
createSubOptions(
0);

ofMenu.onchange 
= function() {createSubOptions(this.selectedIndex);};

function createMainOptions() {
     
for(var i=0;i<fMenu.length;i++)ofMenu.options[i] = new Option(fMenu[i],fValue[i]);
}

function createSubOptions(j) {
     
with(osMenu) {
         length
=0;
         
for(var i=0;i<sMenu[j].length;i++)osMenu.options[i] = new Option(sMenu[j][i],sValue[j][i]);
     }

}

</SCRIPT>

posted on 2007-12-20 21:20  Squall  阅读(268)  评论(0编辑  收藏  举报

导航