<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>多级关联菜单数据库版</title>
<!–
数据库:test.mdb
表:dbselect
表结构:id(自增) school(文本) department(文本) grade(文本) student(文本)
IE6,NS7,Mozilla下测试通过
–>
</head>
<body>
<form name="frm">
<select name=school onchange="MulSelect(1)"></select>
<select name=department onchange="MulSelect(2)"></select>
<select name=grade onchange="MulSelect(3)"></select>
<select name=student></select>
</form>
<script>
var arrSel=["school","department","grade","student"]
arrData=[];
<%
dim conn,rs
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.mappath("test.mdb") & ";Persist Security Info=False"
set rs=conn.execute("select * from dbselect")
do while not rs.eof
%>
arrData[arrData.length]=["<%=trim(rs("school"))%>","<%=trim(rs("department"))%>","<%=trim(rs("grade"))%>","<%=trim(rs("student"))%>"]
<%
rs.movenext
loop
rs.close:set rs=nothing
conn.close:set conn=nothing
%>
</script>
<script>
function MulSelect(num){
var find=false
var i,j,arrTemp=[];
for(i=0;i<num;i++)arrTemp[i]=eval("document.frm."+arrSel[i]).value
if(num<arrSel.length)
with(eval("document.frm."+arrSel[num])){
length=0
for(i=0;i<arrData.length;i++){
for(j=0;j<num;j++)if(arrTemp[j]!=arrData[i][j])break;
if(j!=num)continue;
if(length==0 ¦ ¦options[length-1].text!=arrData[i][num]){
for(m=0;m<options.length;m++)if(options[m].text==arrData[i][num])find=true
if(!find)options[options.length]=new Option(arrData[i][num],arrData[i][num])
}
}
MulSelect((num+1))
}
}
MulSelect(0)
</script>
</body>
</html>
多级关联菜单数据库版
466
前一篇