<%
dim conn
dim connstr
on error resume next
connstr="DBQ="+server.MapPath("test.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.CreateObject("ADODB.CONNECTION")
conn.open connstr
%>
<script language = "JavaScript">
sall=new Array();
<%
Dim i
i=0
set rs=conn.execute("select * from subject")
do while not rs.eof
%>
sall[<%=i%>]=new Array("<%=rs("subjectname")%>","<%=rs("departid")%>","<%=rs("subjectid")%>");
<%
i=i+1
rs.movenext
loop
rs.close
%>
function changeselect(selvalue)
{
document.myform.Nclassid.length=0;
var selvalue=selvalue;
var i;
for(i=0;i<sall.length;i++)
{
if(sall[1]==selvalue)
{
var newOption1=new Option(sall[0],sall[2]);
document.all.Nclassid.add(newOption1);
}
}
}
</script>
<form method="post" name="myform" action="ru_query.asp">
<select
name="classid"
onChange="changeselect(document.myform.classid.options[document.myform.classid.selectedIndex].value)"
size="1">
<option selected value="">未指定条件</option>
<%
set rs1=conn.execute("select * from depart")
do while not rs1.eof
response.write
"<option
value='"&rs1("departid")&"'>"&rs1("departname")&"</option>"&chr(13)+chr(10)
rs1.movenext
loop
rs1.close
%>
</select>
<select name="Nclassid">
<option selected value="">未指定</option>
</select>
数据库设计
表depart
字段
departID 自动编号
departName 文本 '省份
表subject
字段
subjectID 自动编号
subjectName 文本 '城市
departID 数字'所属省份ID