多级菜单关联

<html>
<head>
<title>关联菜单</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
body,select
{
font-size:9pt;
font-family:Verdana;
}
a
{
color:red;
text-decoration:none;
}
a:hover{
text-decoration:underline;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function Dsy()
{
this.Items = {};
}
Dsy.prototype.add = function(id,iArray)
{
this.Items[id] = iArray;
}
Dsy.prototype.Exists = function(id)
{
if(typeof(this.Items[id]) == "undefined") return false;
return true;
}

function change(v){
var str="0";
for(i=0;i<v;i++){ str+=("_"+(document.getElementById(s[i]).selectedIndex-1));};
var ss=document.getElementById(s[v]);
with(ss){
length = 0;
options[0]=new Option(opt0[v],opt0[v]);
if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v)
{
if(dsy.Exists(str)){
ar = dsy.Items[str];
for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]);
if(v)options[1].selected = true;
}
}
if(++v<s.length){change(v);}
}
}

var dsy = new Dsy();

dsy.add("0",["理事会","项目开发部","市场产品部","人力资源部","技术支持部","秘书部"]);

dsy.add("0_0",["理事会"]);

dsy.add("0_1",["项目A组","项目B组","项目C组","项目D组"]);

dsy.add("0_2",["调研宣传组","产品设计组"]);

dsy.add("0_3",["HR-A组","HR-B组"]);

dsy.add("0_4",["技术A组","技术B组","技术C组"]);

dsy.add("0_5",["公关A组","公关B组","档案办"]);

 


//-->
</SCRIPT>
<SCRIPT LANGUAGE = JavaScript>
<!--

var s=["s1","s2"];
var opt0 = ["部门","小组"];
function setup()
{
for(i=0;i<s.length-1;i++)
document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
change(0);
}
//-->
</SCRIPT>
</head>
<body bgcolor="#E0E0E0" onload="setup()">
多级关联菜单:
<form name="frm">
<select id="s1"><option>部门</option></select>
<select id="s2"><option>小组</option></select>
</form>
</body>
</html>

 

posted @ 2011-10-05 15:12  残星  阅读(274)  评论(0编辑  收藏  举报