求好用的三层树状菜单

zhangfengyi 2009-08-10 04:45:25
求好用的三层树状菜单,ASP的,如下图所示
...全文
323 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangfengyi 2009-08-23
  • 打赏
  • 举报
回复
这个是我前天才开发出来的,网上的不好用,三级树状结构必须点到第三级才显示内容,而客户要求每点一级都显示不同的内容,就是这样的http://www.ebitbj.com/asus.asp,把代码贴出来,与大家共享.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>华硕专区</title>
<script type="text/javascript">
function showList(div_id)
{
var obj = document.getElementById(div_id + "_ljf");
var click_obj = document.getElementById(div_id);
var text = click_obj.innerHTML;

if(obj.style.display == "none")
{
var str = div_id.substring(0,div_id.length-1);
var num = div_id.replace(str,"");
for(i=1;;i++)
{
if(!document.getElementById(str+i)) break;
document.getElementById(str+i+"_ljf").style.display = "none";
var iHtml = document.getElementById(str+i).innerHTML;
document.getElementById(str+i).innerHTML = iHtml.replace("-","+");
}

obj.style.display = "block";
click_obj.innerHTML = text.replace("+","-");
}
else
{
obj.style.display = "none";
click_obj.innerHTML = text.replace("-","+");
}
}
</script>
</head>
<body>
<div style="background-image: url(../image/left1.jpg);width:171px;height:35px;text-align:center;padding-top:10px;">华硕专区</div>
<%dbdns=""%>
<!--#include file=inc/conn.asp-->
<%sql="select * from zq_aa where a_id=1"
rs.open sql,conn,1,1
dim i
i=1
do while not rs.eof%>
<div id="pNode1<%=i%>" style="padding-left:20px;cursor:pointer;background-image: url(../image/left2.jpg);height:21px;padding:5px;padding-left:15px;padding-top:8px;">
<div id="pNode<%=i%>" onclick="showList(this.id);" style="cursor:pointer; width:10px;float:left;">+ </div> <div id=pNode<%=i%> style="width:60px;"><a href=asus_frame.asp?id=<%=rs("id")%>&name1=<%=rs("name")%> target="view"><%=rs("name")%></a> </div></div>
<div id="pNode<%=i%>_ljf" style="display:none;">
<%set rs1=server.CreateObject("adodb.recordset")
sql1="select * from zq_aaa where aa_id="&rs("id")
rs1.open sql1,conn,1,1
j=1
do while not rs1.eof%>
<div id="pNode1<%=i%>_sub1<%=j%>" style="cursor:pointer;background-image: url(../image/left2.jpg);height:21px;padding:5px;padding-left:20px;padding-top:8px;">
<div id="pNode<%=i%>_sub<%=j%>" onclick="showList(this.id);" style="padding-left:10px; cursor:pointer;float:left;">+ </div> <div id="pNode<%=i%>_sub<%=j%>" style="width:110px;"><a href=asus_frame1.asp?id=<%=rs1("id")%>&name1=<%=rs1("name")%> target="view"><%=rs1("name")%></a></div></div>
<div id="pNode<%=i%>_sub<%=j%>_ljf" style="display:none;">

<%set rs2=server.CreateObject("adodb.recordset")
sql2="select * from zq_aaaa where aaa_id="&rs1("id")
rs2.open sql2,conn,1,1
k=1
do while not rs2.eof%>
<div id="pNode1<%=i%>_sub1<%=j%>_s1<%=k%>" style="cursor:pointer;background-image: url(../image/left2.jpg);height:21px;padding:5px;padding-left:40px;padding-top:8px;">·<a href=asus_frame2.asp?id=<%=rs2("id")%>&name1=<%=rs2("name")%> target="view"><%=rs2("name")%></a></div>
<%k=k+1
rs2.movenext
loop%>


</div>
<%j=j+1
rs1.movenext
loop%>
</div>
<%i=i+1
rs.movenext
loop%>

</body>
</html>
这个如果大家没有背景文件随便做一个放上就行了,还需要三个数据表,分别是zq_aa,zq_aaa,zq_aaaa,当然你可以用别的名字,结构分别是:
id,a_id,name
id,a_id,aa_id,name
id,a_id,aa_idaaa_id,name
如果有不明白的地方可以问我
zhangfengyi 2009-08-14
  • 打赏
  • 举报
回复
还有没有其他支持三级分类的树形结构
  • 打赏
  • 举报
回复
ASP无限带权限树:http://www.myziy.com/show.php?contentid=123

28,406

社区成员

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

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