求三级联动中的传递值
本帖最后由 x04294940191 于 2014-01-04 13:06:58 编辑 下面是一个直接通过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;
var j;
document.myform.class3.options[0] = new Option('==请选择姓名==','');
for (j=0;j < onecount2; j++)
{
if (subcat2[j][1] == villageid)
{
document.myform.class3.options[document.myform.class3.length] = new Option(subcat2[j][0], subcat2[j][2]);
}
}
}
</script>
</head>
<body>
<form method="POST" target="mainFrame" action="app.asp" name="myform">
<p><br>
<td height="100"><p align="center">
<form>
<p align="center"><br>选择学校:
<select name="class1" onChange="changelocation(document.myform.class1.options[document.myform.class1.selectedIndex].value)">
<option selected value="">==请选择学校==</option>
<%
sql1 = "select * from loaction order by loactionname asc"
set rs1 = conn.Execute (sql1)
do while not rs1.eof
%>
<option value="<%=rs1("loactionid")%>"><%=rs1("loactionname")%></option>
<%
rs1.movenext
loop
rs1.close
set rs1 = nothing
conn.Close
set conn = nothing
%>
</select>
</p>
<p align="center">选择班级:
<select name="class2"onChange="changelocation2(document.myform.class2.options[document.myform.class2.selectedIndex].value)">
<option selected value="">==请选择班级==</option>
</select>
</p>
<p align="center">选择姓名:
<select name="class3">
<option selected value="">==请选择姓名==</option>
</select>
<p align="center">验 证 码:
<%
dim num1,rndnum
Randomize
Do While Len(rndnum)<4
num1=CStr(Chr((57-48)*rnd+48))
rndnum=rndnum&num1
loop
session("verifycode")=rndnum
%>
<input class="input" type="text" name="verifycode" size="12" font face="宋体" style="font-size: 9pt">
<b><span style="background-color: #FFFFFF"><font color=#000000><%=session("verifycode")%></font></span></b>
<p align="center">
<input type="submit" value="开始查询 " >
<input type="reset" value="重新填写" >
</p>
<p align="center">
</p>
</form></td>
</tr>
</table>
<table border="1" width="240" cellspacing="0" cellpadding="0" bordercolor="#0080C0" id="table1" style="border-collapse: collapse" height="25">
<td height="25" bgcolor="#0080C0">
<p align="center"><b><font color="#FFFFFF" style="font-size: 9pt">
管理员帐号入口:</font></b> <a href="admin/login.asp" target="_blank" class="STYLE1">进入管理</a></p></td>
</tr>
</table>
<p>
</div>
</body>
</html>
[解决办法]
app.asp可以这样获取这三个值
dim class1,class2,class3
class1=request.form("classid1")
class2=request.form("class2")
如此,,,下面提保存语句。