[CODE]
我换了另一个思路,就是在导出第一个下拉菜单 的时候,先根据第一个下拉菜单的值找出第二个下拉菜单的列表值以数组的形式存储起来,然后根据在客户端根据第一个下拉菜单 的值的改变从不同的数组中导出第二个下拉菜单的值,可是我在运行的时候为什么整个页面都是空白的。什么也没有呀,请高手指点。
以下是conn1.aspr代码,数据库还是之前的那个。
<%
dim conn
dim connstr
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("data/data.mdb")
conn.Open connstr
%>
<%
sub connclose()
conn.close
set conn=nothing
end sub
%>
<html>
<head>
<title>动态生成下拉菜单</title>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<script language=javascript>
subcat = new Array();
<%
dim rstmp,rstmp2,sql
Set rs1=Server.CreateObject("ADODB.recordset")
Set rs2=Server.CreateObject("ADODB.recordset")
sql="select distinct sever from server"
rs1.open sql,conn,1,1
j=1
do while not rs1.eof
sql="select * from server where sever=" & rs1("sever") & " order by id desc"
rs2.open sql,conn,1,1
do while not rs2.eof
%>
subcat[<%=j%>]=new Array("<%=rs1("name")%>","<%=rs2("name")%>");
<%j=j+1
rs2.movenext
loop
rs2.close
rs1.movenext
Loop
rs1.close
%>
var countj=<%=j-1%>;
function rewritelist(oid)
{ document.form1.server2.length=0;
document.form1.server2.options[document.form1.server2.length]=new Option("请选择","");
for(var i=1;i<=countj;i++)
if (subcat[i][0]==oid)
document.form1.server2.options[document.form1.server2.length] =
new Option(subcat[i][1],subcat[i][1]);
}
</script>
</head>
<body>
<table>
<form action="conn1.asp" name="form1" method="post" >
<tr class=backq>
<td align="right">请选择分区</td>
<td width="34%">
<select size="1" name="server1" onclick="rewritelist(this.options[this.selectedIndex].value)" >
<option>请选择分类</option>
<%
rs1.open "select distinct sever from server",conn,1,1
do while not rs1.eof
%>
<option value="<%=rs1("sever")%>"><%=rs1("sever")%></option>
<%
rs1.movenext
Loop
%>
</select></td>
<tr><td align="right">请选择小类</td>
<td>
<select name=server2>
<option selected>请选择小类</option>
</select>
</td>
</tr>
</form>
</table>
</body>
</html>
[/CODE]