高手求救:联动菜单的问题! 急!

zlydaaa 2003-09-30 09:57:41
我的一个类似于省和县市的跳转菜单放在表单外面运行通过,但是把它放到一个表单里面,也就是<form></form>之间的时候,第二个菜单(县市)就显示不了,


<%
Dim Rs,sql,i,rw
Dim MyArray()
set rs=server.createobject("adodb.recordset")
SQL="select * from province order by proNum"
Rs.Open SQL,conn,3,2
Rs.MoveFirst
redim MyArray(Rs.RecordCount-1)
%>


<select id=select1 style="WIDTH: 150px" name=province>
<option value='all' selected>--省名--</option>
<option value=<%=Rs("proNum")%>><%=Rs("proName")%></option>
<%
MyArray(0)=Rs("proNum")
Rs.MoveNext
for i=1 to Rs.RecordCount-1
%>
<option value=<%=Rs("proNum")%>><%=Rs("proName")%></option>
<%
MyArray(i)=Rs("proNum")
Rs.MoveNext
next
%>
</select>
<%
Rs.Close
%>
</td>
<td width="96">
<%
for i=0 to ubound( MyArray)
SQL="select * from City where CityId like '" & MyArray(i) & "%'"
'Response.End
Rs.Open SQL,conn,3,2
if Rs.RecordCount >0 then
Rs.MoveFirst
%>
<SELECT id=select<%=MyArray(i)%> style="WIDTH: 200px;display='none'" name=city>
<option selected value='all'>-----县市名-----</option>
<%do while not Rs.EOF %>
<OPTION value="<%=Rs("CityId")%>"><%=Rs("CityName")%></OPTION>
<%
Rs.MoveNext
loop
%>
</SELECT>
<%
end if
Rs.Close
next
%>
<SCRIPT LANGUAGE=vbscript>
<!--

dim obj,lastObj
lastObj="select01"

window.execScript "select01.style.display='block'" ,"vbs"
Sub select1_onchange
obj="select"+select1.value
if obj<>lastObj and isobject(eval(obj)) then
window.execScript Obj & ".style.display='block'" ,"vbs"
window.execScript lastObj & ".style.display='none'" ,"vbs"
lastObj="select"+ select1.value
end if
End Sub

-->
</SCRIPT>



大概的也就这样,其实这段代码还是我在CSDN的论坛的一篇帖子上找的,自己改了一点,
在<form>表单外能实现,但是移到表单内,CITY菜单就没有了
...全文
38 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
tigerwen01 2003-09-30
  • 打赏
  • 举报
回复
请参考:
http://www.csdn.net/develop/read_article.asp?id=18690
http://www.csdn.net/develop/read_article.asp?id=18691
ttt2 2003-09-30
  • 打赏
  • 举报
回复
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head>
<%
xqid=request.querystring("xqid")
lid=request.querystring("lid")

set cn=server.createobject("adodb.connection")
cn.open "driver={sql server};uid=sa;pwd=abc;server=zhao;database=test"
set rs=server.createobject("adodb.recordset")
rs.open "select * from w_xq",cn,1,3

set rsl=server.createobject("adodb.recordset")

%>
<script language="javascript">

function s()
{

document.form1.lid.options[1]=null
document.form1.lid.options[0]=null
}


function changel(a)
{
if(a==0)
{
//alert("0")
return false
}


for(i=document.form1.lid.options.length-1;i>=0;i--)
{
document.form1.lid.options[i]=null
}

switch(a)
{
<%
while not rs.eof
%>
case "<%=rs("id")%>":
document.form1.lid.options[document.form1.lid.options.length]=new Option("---请选择---","0")
<%
rsl.open "select * from w_l where xqid="&rs("id"),cn,1,3
while not rsl.eof
%>

document.form1.lid.options[document.form1.lid.options.length]=new Option("<%=rsl("name")%>","<%=rsl("id")%>")
<%if lid<>"" and cint(lid)=rsl("id") then
%>
document.form1.lid.options.selectedIndex=document.form1.lid.options.length-1
<%end if%>
<%
rsl.movenext
wend
rsl.close
%>

break;
<%
rs.movenext
wend
%>

}



}



function changef(a,b)
{
if (b==0)
{
return false
}
location.href="index.asp?xqid="+a+"&lid="+b
}


</script>
<body>
<form name="form1" method="post" target=_blank action="select.asp">
<select name="xqid" onchange="changel(this.value)">
<option value="0">---请选择---</option>
<%
rs.movefirst
while not rs.eof
%>
<option value="<%=rs("id")%>" <%if cint(xqid)=rs("id") then%>selected<%end if%>><%=rs("name")%></option>
<%
rs.movenext
wend
%>
</select>
<!--onchange="changef(document.form1.xqid.value,this.value)"-->
<select name="lid" >
<option value="0">---请选择---</option>
</select> <input type="button" value="清除" name="B1" onclick="s()">
<input type="submit" value="提交" name="B2"></form>
<%
if xqid<>"" then
%>
<script language="javascript">
changel('<%=xqid%>')
</script>
<%end if%>
</body>

</html>
ttt2 2003-09-30
  • 打赏
  • 举报
回复
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head>
<%
xqid=request.querystring("xqid")
lid=request.querystring("lid")

set cn=server.createobject("adodb.connection")
cn.open "driver={sql server};uid=sa;pwd=abc;server=zhao;database=test"
set rs=server.createobject("adodb.recordset")
rs.open "select * from w_xq",cn,1,3

set rsl=server.createobject("adodb.recordset")

%>
<script language="javascript">

function s()
{

document.form1.lid.options[1]=null
document.form1.lid.options[0]=null
}


function changel(a)
{
if(a==0)
{
//alert("0")
return false
}


for(i=document.form1.lid.options.length-1;i>=0;i--)
{
document.form1.lid.options[i]=null
}

switch(a)
{
<%
while not rs.eof
%>
case "<%=rs("id")%>":
document.form1.lid.options[document.form1.lid.options.length]=new Option("---请选择---","0")
<%
rsl.open "select * from w_l where xqid="&rs("id"),cn,1,3
while not rsl.eof
%>

document.form1.lid.options[document.form1.lid.options.length]=new Option("<%=rsl("name")%>","<%=rsl("id")%>")
<%if lid<>"" and cint(lid)=rsl("id") then
%>
document.form1.lid.options.selectedIndex=document.form1.lid.options.length-1
<%end if%>
<%
rsl.movenext
wend
rsl.close
%>

break;
<%
rs.movenext
wend
%>

}



}



function changef(a,b)
{
if (b==0)
{
return false
}
location.href="index.asp?xqid="+a+"&lid="+b
}


</script>
<body>
<form name="form1" method="post" target=_blank action="select.asp">
<select name="xqid" onchange="changel(this.value)">
<option value="0">---请选择---</option>
<%
rs.movefirst
while not rs.eof
%>
<option value="<%=rs("id")%>" <%if cint(xqid)=rs("id") then%>selected<%end if%>><%=rs("name")%></option>
<%
rs.movenext
wend
%>
</select>
<!--onchange="changef(document.form1.xqid.value,this.value)"-->
<select name="lid" >
<option value="0">---请选择---</option>
</select> <input type="button" value="清除" name="B1" onclick="s()">
<input type="submit" value="提交" name="B2"></form>
<%
if xqid<>"" then
%>
<script language="javascript">
changel('<%=xqid%>')
</script>
<%end if%>
</body>

</html>

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧