新微赢技术网
标题:
请教高手,ASP中两级列表联动功能实现问题
[打印本页]
作者:
阿俊
时间:
2010-1-10 07:13
标题:
请教高手,ASP中两级列表联动功能实现问题
我用的是Access数据库
作业的目的是实现两级列表框的联动功能,两个列表框的数据都是从数据库中读取
下一级数据按上一级数据进行显示 ,结果是上级列表可以显示,下级列表无任何反应
下面是我写的代码
希望大家帮忙修改
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/connbooks.asp" -->
<%
//下面是定义了记录集Rs1用于上级列表框赋值
Dim Rs1
Dim Rs1_numRows
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Rs1.ActiveConnection = MM_connbooks_STRING
Rs1.Source = "SELECT * FROM prt"
Rs1.CursorType = 0
Rs1.CursorLocation = 2
Rs1.LockType = 1
Rs1.Open()
Rs1_numRows = 0
%>
<%
Dim Rs2
Dim Rs2_numRows
Set Rs2 = Server.CreateObject("ADODB.Recordset")
Rs2.ActiveConnection = MM_connbooks_STRING
Rs2.Source = "SELECT prt.* ,city.* FROM prt,city WHERE city.pID=prt.pID"
Rs2.CursorType = 0
Rs2.CursorLocation = 2
Rs2.LockType = 1
Rs2.Open()
Rs2_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档 </title>
</head>
<body>
<form action="" method="post" name="myform" id="myform">
<table width="210" height="162" border="0" align="center">
<tr>
<td>省份 </td>
<td> <select name="selectpn" id="selectpn">
<%
While (NOT Rs1.EOF)
%>
<option value=" <%=(Rs1.Fields.Item("pname").Value)%>"> <%=(Rs1.Fields.Item("pname").Value)%> </option> //对上级列表框赋值
<%
Rs1.MoveNext()
Wend
If (Rs1.CursorType > 0) Then
Rs1.MoveFirst
Else
Rs1.Requery
End If
%>
</select> </td>
</tr>
<tr>
<td>城市 </td>
<td> <select name="selectcity" id="selectcity">
</select> </td>
<script language="JavaScript"> //写了一个JAVA脚本,对下级列表框赋值,我想问题可能就出在这里
<!--
var temp=document.myform.selectcity
function redirect(x){
var i
for (var m=temp.options.length-1;m>0;m--)
temp.options[m]=null
<%while not Rs2.eof%>
cnt= <%=(Rs2.Fields.Item("pID").Value)%>
if(cnt==x)
<option value=" <%=(Rs2.Fields.Item("cityname").Value)%>"> <%=(Rs2.Fields.Item("cityname").Value)%> </option>
<%
Rs2.movenext
wend
%>
}
//-->
</script>
</tr>
</table>
</form>
</body>
</html>
<%
Rs1.Close()
Set Rs1 = Nothing
%>
<%
Rs2.Close()
Set Rs2 = Nothing
%>
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2