下面是一个直接通过access数据库实现学校、班级到姓名的三级联动选择表单代码,经过本地测试通过。我还有一个app.asp文件,运行时需要加载这个三级联动表单中的学校、班级和姓名的值,这个值是什么(我以为是class1、class2和class3,结果不对)?给写一下。app.asp怎样获取这三个值?给写下。谢谢!
<html>
<br>
<head>
<title>小学成绩查询系统</title>
<link rel="stylesheet" type="text/css" href="css.css">
</head>
<body>
<div align="center"><table border="1" width="240" cellspacing="0" cellpadding="0" bordercolor="#0080C0" id="table1" style="border-collapse: collapse" height="131">
<tr>
<td height="25" bgcolor="#0080C0"><p align="center"><b><font color="#FFFFFF" style="font-size: 9pt"> 学生成绩查询</font></b></td>
</tr>
<tr>
<html>
<head>
<title>asp三级联动菜单(含数据库)</title>
<%
dim conn
dim rs
dim sql
dim count
dim rs1
dim sql1
dim rs2
dim sql2
dim count2
dim connstr
'Download by http://www.codefans.net
connstr="DBQ="+server.mappath("class.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
sql = "select * from district order by locationid asc"
set rs = conn.execute(sql)
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%=trim(rs("districtname"))%>","<%= trim(rs("locationid"))%>","<%= trim(rs("districtid"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
set rs=nothing
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.myform.class2.length = 0;
document.myform.class3.length = 0;
document.myform.class3.options[0] = new Option('==请选择姓名==','');
var locationid=locationid;
var i;
document.myform.class2.options[0] = new Option('==请选择班级==','');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.class2.options[document.myform.class2.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
<%sql2 = "select * from village order by districtid asc"
set rs2 = conn.execute(sql2)
%>
<script language = "JavaScript">
var onecount2;
onecount2=0;
subcat2 = new Array();
<%
count2 = 0
do while not rs2.eof
%>
subcat2[<%=count2%>] = new Array("<%= trim(rs2("villagename"))%>","<%= trim(rs2("districtid"))%>","<%= trim(rs2("villagename"))%>");
<%
count2 = count2 + 1
rs2.movenext
loop
rs2.close
set rs2=nothing
%>
onecount2=<%=count2%>;
function changelocation2(villageid)
{
document.myform.class3.length = 0;
var villageid=villageid;