<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" action=2.asp>
<% set rs=server.CreateObject("adodb.recordset")
sq="select * from class1"
rs.open sq,conn,1,1
%>
<select name="class1" onChange="changeclass2()" multiple>
<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()" multiple>
<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
%>
<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;
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]));
}
}
}
</script>
<input type="submit" value="提交">
</form>
</body>
</html>