ASP二级联动菜单如何变成三级联动.急!!

这是我二级联动能运动的代码..<%sql="select*fromBigClass"rs.opensql,conn,1,1ifrs.eofandrs.bofthenres... 这是我二级联动能运动的代码..
<%
sql = "select * from BigClass"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
else
%>
<select name="BigClassName" onChange="changelocation(document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)" size="1">
<option selected value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option>
<%
dim selclass
selclass=rs("BigClassName")
rs.movenext
do while not rs.eof
%>
<option value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select> <select name="SmallClassName">
<option value="" selected>不指定小类</option>
<%
sql="select * from SmallClass where BigClassName='" & selclass & "'"
rs.open sql,conn,1,1
not(rs.eof and rs.bof) then
%>
<option value="<%=rs("SmallClassName")%>"><%=rs("SmallClassName")%></option>
<%
do while not rs.eof%>
<option value="<%=rs("SmallClassName")%>"><%=rs("SmallClassName")%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
大侠们帮个忙..
啊?根据你那个我前后台的都得修改了..
我发现问题所在.
sql="select * from SSmallClass where SmallClassName='" & SmallClassName & "'"里面..SmallClassName这个值要动态显示怎么取值才是正确的?二级联动时随便选择哪个第三联动的都是不变...
我的前面参考了大类取值后..修改的
dim SSclass
SSclass=rs("SmallClassName")
rs.movenext

sql="select * from SSmallClass where SmallClassName='" & SSclass & "'"
值是取到了..但不会发生变化..一直是三个不变..
展开
 我来答
mngenius
2007-11-01 · TA获得超过3165个赞
知道大有可为答主
回答量:2192
采纳率:0%
帮助的人:0
展开全部
根据这个修改试试

<!--#include file="edu_inc/conn.asp"-->
<%
dim cid,coid
cid = request("cid") 'cid 大类id
coid = request("coid") 'coid 中类id
set rs=server.createobject("adodb.recordset")
sql = "select * from edu_c" '表一 大类表
rs.open sql,conn,1,1
strOption1 = "<option value='' selected ></option>"
do while not rs.eof
if cstr(rs("id")) = cstr(cid) then
strOption1 = strOption1 & "<option value='" & rs("id") & "' selected>" & rs("c_name") & "</option>"
else

strOption1 = strOption1 & "<option value='" & rs("id") & "'>" & rs("c_name") & "</option>"

end if
rs.movenext
&nbs
p; loop

rs.close

if cid <> "" then
sql = "select * from edu_co where c_id=" & cid '表二 中类表 bid==表一中的id

rs.open sql,conn,1,1
strOption2 = "<option value='' selected >不指定小类</option>"

do while not rs.eof
if cstr(rs("id")) = cstr(coid) then
strOption2 = strOption2 & "<option value='" & rs("id") & "' selected>" & rs("co_name") & "</option>"
else
strOption2 = strOption2 & "<option value='" & rs("id") & "'>" & rs("co_name") & "</option>"
&nbs

p; end if
rs.movenext
loop
rs.close
end if

if coid <> "" then
sql = "select * from edu_s where co_id= " & coid '表三 小类表 mid==表二的id
rs.open sql,conn,1,1
strOption3 = "<option value='' selected >不指定小小类</option>"
while not rs.eof
if cstr(rs("id")) = cstr(sid) then
strOption3 = strOption3 & "<option value='" & rs("id") & "' selected>" & rs("s_name") & "</option>"
else
strOption3 = strOption3 & "<option
value='" & rs("id") & "'>" & rs("s_name") & "</option>"
end if

rs.movenext
wend
rs.close
end if

%>
<select onChange="changeb(this.value)" name="cid"><%=strOption1%></select>
<select onChange="change(this.value)" name="coid"><%=strOption2%></select>
<select name="sid"><%=strOption3%></select>
<script language="javascript">
<!--
function changeb(cid){
location.assign("three.asp?action=s_s&cid=" + cid);
}

function change(coid){
location.assign("three.asp?action=s_s&cid=<%=cid%>&coid=" + coid);
}
-->
</script>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
yiguang222
推荐于2016-01-04 · TA获得超过128个赞
知道小有建树答主
回答量:155
采纳率:0%
帮助的人:180万
展开全部
我有 不过和你不一样!
<%
Set Conn = Server.CreateObject("ADODB.Connection")
StrCnn = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("date/yiguang.mdb") & ";"
Conn.Open StrCnn
%>
</head>
<title>易氏 ASP+ACCESS三级联动</title><body>
<form name="myform" method="post">
<%
set rs=server.CreateObject("adodb.recordset")
sq="select * from edu_c"
rs.open sq,conn,1,1
%>
<select name="class1" onChange="changeclass2();changeclass3()">
<option value="" selected>选择一级目录</option>
<%
while not rs.eof
%>
<option value="<%=rs("c_name")%>"><%=rs("c_name")
%>
</option>
<%
rs.movenext
wend
rs.close
%>
</select>
<select name="class2" onChange="changeclass3()">
<option value="" selected>选择二级目录</option>
</select>
<select name="class3">
<option value="" selected>选择三级目录</option>
</select>
<%
sql="select * from edu_co"
rs.open sql,conn,1,1
num=rs.recordcount
str=""
for i=1 to rs.recordcount
str=str&rs("c_name")&"-"&rs("co_name")&","
if rs.eof then exit for
rs.movenext
next
rs.close
%>
<%
sql="select * from edu_s"
rs.open sql,conn,1,1
num2=rs.recordcount
str2=""
for i=1 to rs.recordcount
str2=str2&rs("co_name")&"-"&rs("s_name")&","
if rs.eof then exit for
rs.movenext
next
rs.close
%>
<!--下面是实现动态改变下一级菜单的脚本代码-->
<script LANGUAGE="javascript">

arr="<%=str%>".split(",");
a=arr.length
ar=new Array()
for (i=0;i<a;i++){
ar[i]=arr[i].split("-");
}
onecount=ar.length;

arr2="<%=str2%>".split(",");
a2=arr2.length
ar2=new Array()
for (i=0;i<a2;i++){
ar2[i]=arr2[i].split("-");
}
onecount2=ar2.length;

function changeclass2() {
document.myform.class2.length=0
lid=myform.class1.value;
for (i=0;i<onecount;i++) {
if (ar[i][0] == lid) {
document.myform.class2.options.add(new Option(ar[i][1], ar[i][1]));
}
}
}
function changeclass3() {
document.myform.class3.length=0
lid2=myform.class2.value;
for (i=0;i<onecount2;i++) {
if (ar2[i][0] == lid2) {
document.myform.class3.options.add(new Option(ar2[i][1], ar2[i][1]));
}
}
}
</script>
</form>
</body>
</html>
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式