asp关联二级菜单问题

该代码只能看大类的列表,小类的看不到,请各位大侠指点一下,运行成功后我会追加100分!<!--#includefile="conn.asp"--><html><%dimc... 该代码只能看大类的列表,小类的看不到,请各位大侠指点一下,运行成功后我会追加100分!

<!--#include file="conn.asp" -->
<html>
<%
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from shop_nclass order by nclassidorder"
rs.open sql,conn,1,1
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("nclass"))%>","<%= trim(rs("anclassid"))%>","<%= trim(rs("nclassid"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;

function changelocation(locationid)
{
document.form1.sid.length = 0;

var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.form1.sid.options[document.form1.sid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

}
</script>
<body>
<table border="0" width="100%" id="table1" cellpadding="4" style="border:1px solid #183789; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px">
<form action=save.asp method=post name=form1 onSubmit="return checkdata();">
<tr>
<td width="100%" colspan="2" background="Image/admin_bg_1.gif" height="25">
<font color="#FFFFFF"><b>商品发布:</b></font></td>
</tr>
<tr>
<td width="168">所属分类:</td>
<td width="802"><select size="1" name="bid" onChange="changelocation(document.form1.bid.options[document.form1.bid.selectedIndex].value)">
<option>≡≡请选择大类≡≡</option>
<%sql="select anclassid,anclass from shop_anclass order by anclassidorder"
set rs=conn.execute (sql)
set id=rs("anclassid")
set big_class=rs("anclass")
do while not rs.eof
%>
<option value="<%= trim(rs("anclassid"))%>"><%= trim(rs("anclass"))%></option>
<%rs.movenext
loop
%>

</select> <select name="sid" onChange="change(document.form1.sid.options[document.form1.sid.selectedIndex].value)" style='width:147;background-color:white;font-size:12;color:black; height:18' size="1">
<option selected>≡≡请选择小类≡≡</option></select></td>
</form>
</table>

</body>

</html>
我要的是点击选择大类后,从小类里面出来与之相关的小类列表!大家多多帮忙,没啥说的,加分!
展开
 我来答
_传_奇
2009-05-21 · TA获得超过267个赞
知道答主
回答量:467
采纳率:0%
帮助的人:0
展开全部
代码是没有问题的,你应该检查一下你绝激的小类是否与大类的连并中袜接做培旅好了,就是一个大类下面的小类的序号是否对应,应该是你的数据库表之间的连接做错了!
夏侯惜萱Ad
2009-05-20 · TA获得超过461个赞
知道答主
回答量:137
采纳率:0%
帮助的人:33.7万
展开全部
<!--#include file="conn.asp" -->
<html>
<%
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from shop_nclass order by nclassidorder"
rs.open sql,conn,1,1
%>
<script language = "JavaScript">扮码
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("nclass"))%>","<%= trim(rs("anclassid"))%>","<%= trim(rs("nclassid"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;

function changelocation(locationid)
{
document.form1.sid.length = 0;

var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.form1.sid.options[document.form1.sid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

}
</script>
<body>
<table border="0" width="100%" id="table1" cellpadding="4" style="border:1px solid #183789; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px">
<form action=save.asp method=post name=form1 onSubmit="return checkdata();">
<tr>
<td width="100%" colspan="2" background="Image/admin_bg_1.gif" height="25">
<font color="#FFFFFF"><b>商品发布:</b></font></td>
</tr>
<tr>
<td width="168">所属分类:</td>
<td width="802"><select size="1" name="bid" onChange="changelocation(document.form1.bid.options[document.form1.bid.selectedIndex].value)">
<option>≡≡请选择大类≡≡</option>
<%sql="select anclassid,anclass from shop_anclass order by anclassidorder"
set rs=conn.execute (sql)
set id=rs("anclassid")
set big_class=rs("anclass")
do while not rs.eof
%>
<option value="<%= trim(rs("anclassid"))%>"><%= trim(rs("anclass"))%></option>
<%rs.movenext
loop
%>

</培缺团select> <select name="sid" onChange="change(document.form1.sid.options[document.form1.sid.selectedIndex].value)" style='width:147;background-color:white;font-size:12;color:black; height:18' size="1">
<option selected>≡≡请选择小类≡≡</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>配橘</td>
</form>
</table>

</body>

</html>

把1、2、3改成你需要添加的内容就行!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式