<html>
<head>
<title>四级连跳</title>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
StrCnn = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("date.mdb") & ";"
Conn.Open StrCnn
%>
</head>
<body>
<form name="myform" method="post">
<% set rs=server.CreateObject("adodb.recordset")
sq="select * from class1"
rs.open sq,conn,1,1
%>
<select name="class1" onChange="changeclass2();changeclass3();changeclass4()">
<option value="" selected>选择一级目录</option>
<%
while not rs.eof
%>
<option value="<%=rs("class1")%>"><%=rs("class1")%></option>
<%rs.movenext
wend
rs.close%>
</select>
<select name="class2" onChange="changeclass3();changeclass4()">
<option value="" selected>选择二级目录</option>
</select>
<select name="class3" onChange="changeclass4()">
<option value="" selected>选择三级目录</option> </select>
<select name="class4">
<option value="" selected>选择四级目录</option> </select>
<%sql="select * from class2"
rs.open sql,conn,1,1
num=rs.recordcount
str=""
for i=1 to rs.recordcount
str=str&rs("class1")&"-"&rs("class2")&","
if rs.eof then
exit for
end if
rs.movenext
next
rs.close
%>
<%
sql="select * from class3"
rs.open sql,conn,1,1
num2=rs.recordcount
str2=""
for i=1 to rs.recordcount
str2=str2&rs("class2")&"-"&rs("class3")&","
if rs.eof then
exit for
end if
rs.movenext
next
rs.close %>
<%
sql="select * from class4"
rs.open sql,conn,1,1
num3=rs.recordcount
str3=""
for i=1 to rs.recordcount
str3=str3&rs("class3")&"-"&rs("class4")&","
if rs.eof then
exit for
end if
rs.movenext
next
rs.close %>
<script LANGUAGE="javascript">
arr="<%=str%>".split(",");
a=arr.length
ar=new Array()
for (i=0;i<a;i++)
{ ar[i]=arr[i].split("-");
}
onecount=ar.length;
arr2="<%=str2%>".split(",");
a2=arr2.length
ar2=new Array()
for (i=0;i<a2;i++)
{
ar2[i]=arr2[i].split("-");
}
onecount2=ar2.length;
arr3="<%=str3%>".split(",");
a3=arr3.length
ar3=new Array()
for (i=0;i<a3;i++)
{
ar3[i]=arr3[i].split("-");
}
onecount3=ar3.length;
function changeclass2()
{ document.myform.class2.length=0
lid=myform.class1.value;
for (i=0;i<onecount;i++)
{
if (ar[i][0] == lid) {
document.myform.class2.options.add(new Option(ar[i][1], ar[i][1]));
}
}
}
function changeclass3()
{
document.myform.class3.length=0
lid2=myform.class2.value;
for (i=0;i<onecount2;i++)
{ if (ar2[i][0] == lid2)
{ document.myform.class3.options.add(new Option(ar2[i][1], ar2
[i][1])); }
}
}
function changeclass4()
{
document.myform.class4.length=0
lid3=myform.class3.value;
for (i=0;i<onecount3;i++)
{ if (ar3[i][0] == lid3)
{ document.myform.class4.options.add(new Option(ar3[i][1], ar3[i][1])); }
}
}
</script>
</body>
</html>