| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1218 人关注过本帖
标题:求实例,从数据库里读出的三级联动菜单,是分别从三个表里读出来的
只看楼主 加入收藏
Kettyjin1983
Rank: 1
等 级:新手上路
帖 子:303
专家分:0
注 册:2007-8-17
结帖率:66.67%
收藏
 问题点数:0 回复次数:8 
求实例,从数据库里读出的三级联动菜单,是分别从三个表里读出来的
求实例,从数据库里读出的三级联动菜单,是分别从三个表里读出来的,我无从下手的。
搜索更多相关主题的帖子: 菜单 实例 表里 数据库 
2008-12-16 13:47
孤独冷雨
Rank: 10Rank: 10Rank: 10
来 自:安徽滁州
等 级:贵宾
威 望:23
帖 子:1247
专家分:1909
注 册:2007-6-4
收藏
得分:0 
你老是问这个问题,还想带实例的,不知道你怎么想的!你用的是什么类型的数据库,怎样取出数据库库中各表以及各表的字段.给你一段自己修改一下:

<%
set rs=server.createobject("adodb.recordset")
rs.open"select * from class_two",conn,1,1
'三级联动下拉列表[数据库版]


‘---------以上是查询出第一级下拉列表的内容-----
’---------以下是用JS来控制程序--------------
%>

<script language = "JavaScript">
var onecount; //定义onecount对像
onecount=0;//初始值为0
subcat = new Array(); //SUBCAT对像是一个新的数组
<%
count = 0 '定义count对像初始值为0
do while not rs.eof '循环表头到表尾
%>
subcat[<%=count%>] = new Array("<%=rs("class_two_text")%>","<%=trim(rs("class_one"))%>","<%=trim(rs("class_two"))%>");
//以上为重点内容,对像数组(subcat[count对像值])= 新数组内容('字段名0','字段名1','字段名2')记住要对应
<%
count = count + 1 '循环count一次,COUNT的值加1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.form.class_two.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[1] == locationid)
{
document.form.class_two.options[document.form.class_two.length] = new Option(subcat[0], subcat[2]);
}
}
}
</script>
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from Class_one" ,conn,1,1
if rs.eof then
response.Write"暂无产品一类名称"
else%>
产品一类
<select name="class_one" id="class_one"
onChange="changelocation(document.form.class_one.options[document.form.class_one.selectedIndex].value)">
<%do while not rs.eof%>
<option value="<%=rs("class_one")%>"><%=rs("class_one_text")%></option>
<%rs.movenext
loop
end if
%>
</select>
产品二类
<select name="class_two"
onChange="three(document.form.class_one.value,document.form.class_two.options[document.form.class_two.selectedIndex].value)">
<option value="请选择条件" selected>请选择条件</option>
</select> <%
set rs=server.createobject("adodb.recordset")
rs.open"select * from class_three",conn,1,1
%> <script language = "JavaScript">
var twocount;
twocount=0;
subthree = new Array();
<%
countb = 0
do while not rs.eof
%>
subthree[<%=countb%>] = new
Array("<%=rs("class_three_text")%>","<%=trim(rs("class_one"))%>","<%=trim(rs("class_two"))%>","<%=trim(rs("class_three"))%>");
<%
countb = countb + 1
rs.movenext
loop
rs.close
%>
twocount=<%=countb%>;
function three(threeid,threeid2)
{
document.form.class_three.length = 0;
var threeid=threeid;
var threeid2=threeid2;
var i;
for (i=0;i < twocount; i++)
{
if ((subthree[1] == threeid) & (subthree[2] == threeid2))
{
document.form.class_three.options[document.form.class_three.length] = new Option(subthree[0],
subthree[3]);
}
}
}
</script>
产品三类
<select name="class_three" id="class_three">
<option value="0" selected>请选择条件</option>
</select>

这里有男女系列成人用品,有时间兄弟们来看一看.
51za.
2008-12-16 15:24
快速回复:求实例,从数据库里读出的三级联动菜单,是分别从三个表里读出来的
数据加载中...
 
   



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

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