标题:请问大神我的二级级联下拉列表的子体为何无法获得数据?谢谢!
取消只看楼主
gnikil
Rank: 2
等 级:论坛游民
帖 子:7
专家分:20
注 册:2010-8-6
结帖率:100%
已结贴  问题点数:20 回复次数:5 
请问大神我的二级级联下拉列表的子体为何无法获得数据?谢谢!
程序代码:
<!--#include file="conn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>New Page 1</title>
</head>
<body>
<%
dim rs
dim sql
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from LOAD_LIST"
rs.open sql,MM_LINE_CONN_STRING,1,1
%>
<SCRIPT language="JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= rs("LINE_NAME")%>","<%= rs("LINE_NAME")%>","<%= rs("LINE_NAME")%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.form1.cid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.form1.cid.options[document.form1.cid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</SCRIPT>
<SCRIPT language="javascript">
<!--
function CheckForm()
{
document.form1.txtcontent.value=document.form1.doc_html.value;
return true
}
//-->
</SCRIPT>
<form name=form1 onsubmit="check()">
景点类别<%
sql = "select * from LINE_ZONE"
rs.open sql,MM_LINE_CONN_STRING,1,1
if rs.eof and rs.bof then
response.write "请先添加景点类别!"
response.end
else
%>
<Select name="sid" onChange="changelocation(document.form1.sid.options[document.form1.sid.selectedIndex].value)" ><%
do while not rs.eof
%><OPTION selected value="<%=rs("LINE_NAME")%>"><%=rs("LINE_NAME")%></OPTION>
<%
rs.movenext
loop
end if
rs.close
%>
</Select>
景点列表<Select name="cid">
<OPTION selected value="">==请选景点==</OPTION>
</Select>
</form>
</body>
</html>
搜索更多相关主题的帖子: color 
2012-10-25 20:45
gnikil
Rank: 2
等 级:论坛游民
帖 子:7
专家分:20
注 册:2010-8-6
得分:0 
没有提示错误,就是第二个子体内容是空的
2012-10-25 22:04
gnikil
Rank: 2
等 级:论坛游民
帖 子:7
专家分:20
注 册:2010-8-6
得分:0 
程序代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>New Page 1</title>
</head>
<body>

<SCRIPT language="JavaScript">
var onecount;
onecount=0;
subcat = new Array();

subcat[0] = new Array("金紫荆广场","金紫荆广场","金紫荆广场");

subcat[1] = new Array("会展中心","会展中心","会展中心");

subcat[2] = new Array("浅水湾","浅水湾","浅水湾");

subcat[3] = new Array("太平山凌霄阁","太平山凌霄阁","太平山凌霄阁");

subcat[4] = new Array("海洋公园","海洋公园","海洋公园");

subcat[5] = new Array("星光大道","星光大道","星光大道");

subcat[6] = new Array("黄大仙庙","黄大仙庙","黄大仙庙");

subcat[7] = new Array("珠宝(都会)","珠宝(都会)","珠宝(都会)");

subcat[8] = new Array("名表(时计宝)","名表(时计宝)","名表(时计宝)");

subcat[9] = new Array("百货(都会)","百货(都会)","百货(都会)");

subcat[10] = new Array("DFS","DFS","DFS");

subcat[11] = new Array("自由活动","自由活动","自由活动");

subcat[12] = new Array("迪士尼","迪士尼","迪士尼");

subcat[13] = new Array("青马大桥","青马大桥","青马大桥");

subcat[14] = new Array("文化中心","文化中心","文化中心");

subcat[15] = new Array("维多利亚港夜游","维多利亚港夜游","维多利亚港夜游");

subcat[16] = new Array("大钟楼","大钟楼","大钟楼");

subcat[17] = new Array("香港湿地公园","香港湿地公园","香港湿地公园");

subcat[18] = new Array("离港","离港","离港");

subcat[19] = new Array("谢瑞麟","谢瑞麟","谢瑞麟");

subcat[20] = new Array("尖东百货","尖东百货","尖东百货");

subcat[21] = new Array("双子星邮轮","双子星邮轮","双子星邮轮");

subcat[22] = new Array("国际免税中心","国际免税中心","国际免税中心");

subcat[23] = new Array("宝瓶星号邮轮","宝瓶星号邮轮","宝瓶星号邮轮");

onecount=24;
function changelocation(locationid)
{
document.form1.cid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.form1.cid.options[document.form1.cid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</SCRIPT>
<SCRIPT language="javascript">
<!--
function CheckForm()
{
document.form1.txtcontent.value=document.form1.doc_html.value;
return true
}
//-->
</SCRIPT>
<form name=form1 onsubmit="check()">
景点类别
<Select name="sid" onChange="changelocation(document.form1.sid.options[document.form1.sid.selectedIndex].value)" ><OPTION selected value="国内景点">国内景点</OPTION>
<OPTION selected value="港澳景点">港澳景点</OPTION>
<OPTION selected value="出境景点">出境景点</OPTION>
<OPTION selected value="台湾景点">台湾景点</OPTION>

</Select>
景点列表<Select name="cid">
<OPTION selected value="">==请选景点==</OPTION>
</Select>
</form>
</body>
</html>
2012-10-25 22:33
gnikil
Rank: 2
等 级:论坛游民
帖 子:7
专家分:20
注 册:2010-8-6
得分:0 
我是想在父体选择了例如港澳景点,那么在字体就查找库中符合字段标注了港澳景点的记录并循环在列表中
2012-10-26 17:53
gnikil
Rank: 2
等 级:论坛游民
帖 子:7
专家分:20
注 册:2010-8-6
得分:0 
我现在用了另外一种比较笨的方法来实现,但是这个要重复打开几次记录集。
程序代码:
<!--#include file="Connections/LINE_CONN.asp" -->
<%
'----------一级菜单列表---------------------------
Dim rs
Dim rs_numRows

Set rs = Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = MM_LINE_CONN_STRING
rs.Source = "SELECT *  FROM LINE_ZONE ORDER BY ID ASC"
rs.CursorType = 0
rs.CursorLocation = 2
rs.LockType = 1
rs.Open()

rs_numRows = 0
'--------国内景点列表------------------------------------
Dim rs1
Dim rs1_numRows

Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.ActiveConnection = MM_LINE_CONN_STRING
rs1.Source = "SELECT *  FROM LOAD_LIST WHERE BZ='国内景点'"
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_LINE_CONN_STRING
rs2.Source = "SELECT *  FROM LOAD_LIST WHERE BZ='港澳景点'"
rs2.CursorType = 0
rs2.CursorLocation = 2
rs2.LockType = 1
rs2.Open()

rs2_numRows = 0
'--------出境景点列表------------------------------------
Dim rs3
Dim rs3_numRows

Set rs3 = Server.CreateObject("ADODB.Recordset")
rs3.ActiveConnection = MM_LINE_CONN_STRING
rs3.Source = "SELECT *  FROM LOAD_LIST WHERE BZ='出境景点'"
rs3.CursorType = 0
rs3.CursorLocation = 2
rs3.LockType = 1
rs3.Open()

rs3_numRows = 0
'--------台湾景点列表------------------------------------
Dim rs4
Dim rs4_numRows

Set rs4 = Server.CreateObject("ADODB.Recordset")
rs4.ActiveConnection = MM_LINE_CONN_STRING
rs4.Source = "SELECT *  FROM LOAD_LIST WHERE BZ='台湾景点'"
rs4.CursorType = 0
rs4.CursorLocation = 2
rs4.LockType = 1
rs4.Open()

rs4_numRows = 0

%>
<SCRIPT language="JavaScript" type="text/javascript">
var sel2=[
[<%do while not rs1.eof%>"<%=rs1("LINE_NAME")%>",<%
rs1.movenext
loop
%>],
[<%do while not rs2.eof%>"<%=rs2("LINE_NAME")%>",<%
rs2.movenext
loop
%>],
[<%do while not rs3.eof%>"<%=rs3("LINE_NAME")%>",<%
rs3.movenext
loop
%>],
[<%do while not rs4.eof%>"<%=rs4("LINE_NAME")%>",<%
rs4.movenext
loop
%>],
];
function getSel2(){
var slt1=document.form.select1;//数组获得一级下拉框对象
var slt2=document.form.select2;//数组获得二级下拉框对象
var slt12=sel2[slt1.selectedIndex-1];//得到对应select1的select2的内容
slt2.length=1;//清空select下拉框
//**将select2数组中的值填充到select2下拉框中**/
         for(var i=0;
         i<slt12.length;i++){slt2[i+1]=new Option(slt12[i]);
         }
} 

</SCRIPT>
<td height="139"> <form name="form" method="POST" action="" charset=UTF-8>
              <select name="select1" id="select1" onChange="getSel2()">
              <OPTION VALUE="0">请选择 </OPTION>
<%do while not rs.eof%><OPTION VALUE="<%=rs("LINE_NAME")%>"><%=rs("LINE_NAME")%></OPTION>
<%
rs.movenext
loop
%></select>
      <select name="select2" id="select2" onchange="">
                <OPTION VALUE="0">请选择</OPTION>
             </select>
                    </form>
<%
rs.Close()
Set rs = Nothing

rs1.Close()
Set rs1 = Nothing

rs2.Close()
Set rs2 = Nothing

rs3.Close()
Set rs3 = Nothing

rs4.Close()
Set rs4 = Nothing
%>



[ 本帖最后由 gnikil 于 2012-10-26 17:57 编辑 ]
2012-10-26 17:54
gnikil
Rank: 2
等 级:论坛游民
帖 子:7
专家分:20
注 册:2010-8-6
得分:0 
上面这个代码子体列表是有了,但是值还是空的。。。请教大神帮帮我
2012-10-29 11:04



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-384422-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.085096 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved