设计一个数据库版的菜单,2个表(一个大类库,一个小类库)大类包括小类,帮忙一起研究一下,分不是问题

xl1860 2004-12-16 02:30:12
形式如下面显示的<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<script language="JavaScript">
function loadThreadFollow(ino){
var targetDiv =eval("foll" + ino);
if (targetDiv.style.display!='block'){
targetDiv.style.display="block";
}else{
targetDiv.style.display="none";
}
}
</script>
<table width="200" border="1">
<tr>
<td><a href=#1 target="_self" onclick="loadThreadFollow(10)">项目一</a></td>
</tr>
<tr>
<td><table width="200" border="1" style="display:none" id="foll10">
<tr>
<td>项目一1</td>
</tr>
<tr>
<td>项目一2</td>
</tr>
<tr>
<td>项目一3</td>
</tr>
</table></td>
</tr>
<tr>
<td><a href=#2 target="_self" onclick="loadThreadFollow(20)">项目二</a></td>
</tr>
<tr>
<td><table width="200" border="1" style="display:none" id="foll20">
<tr>
<td>项目二1</td>
</tr>
<tr>
<td>项目二2</td>
</tr>
<tr>
<td>项目二3</td>
</tr>
</table></td>
</tr>
<tr>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
大家贴过去看就知道了,然后我的意思是,这些东西是从数据库调用的,而不时像上面的静态生成,表结构:大类库里有 (DLBH, DLMC 字段)小类库里有( XLBH, XLMC DLBH 字段)。我的效果是,当我点击大类库里的大类名称(DLMC)就把小类库里的小类名称显示出来(),这个看来很简单,可我做了还是没做完整,大家能帮忙给段代码吗?虚心请教大侠,如问题不清楚可以加我QQ 51284788
...全文
219 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
xl1860 2004-12-20
  • 打赏
  • 举报
回复
取3级菜单呢?
gu1dai 2004-12-16
  • 打赏
  • 举报
回复
一级菜单的动态取值
主要就是table的命名问题
这样写
i=0'rs是一级菜单的纪录集
while not rs.eof
'取二级菜单的值
response.write"<tr><td><a href=#1 target=_self onclick='loadThreadFollow(i)'>"&rs("name")&"</a>"
response.write "<table style=display:none id=foll"&i&">"
while not rs2.eof
<tr>..........
rs2.movenext
wend
i=i+1
rs.movenext
wend

gu1dai 2004-12-16
  • 打赏
  • 举报
回复
楼主原来要的是这个阿
我正好做过和这个一模一样的动态菜单,而且我做的好像是三级菜单
呵呵,值都是从数据库里取得
其实很简单的,只要在写往客户端的时候将递增的数字附到<td>的id的后面,在js里再按照这个判断
gu1dai 2004-12-16
  • 打赏
  • 举报
回复
呵呵,楼主看来是生气了,我来研究下吧
IEEE_China 2004-12-16
  • 打赏
  • 举报
回复
给你一段代码,自己研究研究


'=================================================
'过程名:ShowSearch
'作 用:显示文章搜索表单
'参 数:ShowType ----显示方式。1为纵向,2为横向
'=================================================
sub ShowSearch(ShowType)
dim count
if ShowType<>1 and ShowType<>2 then
ShowType=1
end if
set rs=server.createobject("adodb.recordset")
sql = "select * from SmallClass order by SmallClassID asc"
rs.open sql,conn,1,1
%>
<script language = "JavaScript">
var onecount;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("SmallClassName"))%>","<%= trim(rs("BigClassName"))%>","<%= trim(rs("SmallClassName"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;

function changelocation(locationid)
{
document.myform.SmallClassName.length = 1;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.SmallClassName.options[document.myform.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
<table border="0" cellpadding="2" cellspacing="0" align="center">
<form method="Get" name="myform" action="search.asp">
<tr>
<td height="28"> <select name="Field" size="1">
<option value="Title" selected>产品名称</option>
<option value="Content">产品说明</option>
</select>
<%if ShowType=1 then%>
</td>
</tr>
<tr>
<td height="28">
<%end if%>
<select name="BigClassName" onChange="changelocation(document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)" size="1">
<option selected value="">所有大类</option>
<%
if not (rsBigClass.bof and rsBigClass.eof) then
rsBigClass.movefirst
do while not rsBigClass.eof
response.Write "<option value='" & trim(rsBigClass("BigClassName")) & "'>" & trim(rsBigClass("BigClassName")) & "</option>"
rsBigClass.movenext
loop
end if
%>
</select>
<%if ShowType=1 then%>
</td>
</tr>
<tr>
<td height="28">
<%end if%>
<select name="SmallClassName">
<option selected value="">所有小类</option>
</select>
<%if ShowType=1 then%>
</td>
</tr>
<tr>
<td height="28">
<%end if%>
<input type="text" name="keyword" size=12 value="关键字" maxlength="50" onFocus="this.select();">
<input type="submit" name="Submit" value="搜索"> </td>
</tr>
</form>
</table>
<%
end sub

xl1860 2004-12-16
  • 打赏
  • 举报
回复
你们真不负责,既然我在这里贴出来,我肯定是搜索过的了。那些也试过的了, 但是不是太理想!拜托不要给我地址就完事啊。
friendlyFour 2004-12-16
  • 打赏
  • 举报
回复
你是要知道如何设计sql的表结构吗
whb147 2004-12-16
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3371/3371400.xml?temp=.7781793
whb147 2004-12-16
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3530/3530788.xml?temp=.905987
whb147 2004-12-16
  • 打赏
  • 举报
回复
就是简单的2级联动菜单
你去搜索联动菜单
有很多,我就不贴了

28,390

社区成员

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

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