<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
相关数据库结构请查看
http://blog.youkuaiyun.com/piperzero/archive/2006/07/25/977083.aspx
二级树
如下

同时展开一个
<!--
以下是可以同时只能打开一个子目录的二级数
-->
<!--
#include file="inc/conn.asp"
-->

<%
...
set rs=conn.execute("select * from bigclass")
if rs.recordcount=0 then
Response.Write("暂无")
else
i=0
while not rs.eof
Response.Write("┬ <a href=""javascript:menu"&i&"func()""><b>"&rs("bigclassname")&"</b></a><br>"&CHR(10))
ljh_temp=ljh_temp&"menu"&i&".style.display=""none"";"&CHR(10)
ljh_temp2=ljh_temp2&"function menu"&i&"func()"&CHR(10)&"{"&CHR(10)&"if(menu"&i&".style.display==""none"")"&CHR(10)&"{"&CHR(10)&"startmenu();"&CHR(10)&"menu"&i&".style.display=""block"";"&CHR(10)&"}"&CHR(10)&"else"&CHR(10)&"{"&CHR(10)&"startmenu();"&CHR(10)&"}"&CHR(10)&"}"&CHR(10)&""
set rs2=conn.execute("select * from smallclass where bigclassname='"&rs("bigclassname")&"'")'因为是字符型,所以用到了''
if rs2.recordcount=0 then
Response.Write("<div id=""menu"&i&""" style=""DISPLAY: none"">├ 暂无</div>"&CHR(10))
else
Response.Write("<div id=""menu"&i&""" style=""DISPLAY: none"">"&CHR(10))
while not rs2.eof
Response.Write("├ <a href=""product.asp?bigclassname="&rs("bigclassname")&"&smallclassname="&rs2("smallclassname")&""">"&rs2("smallclassname")&"</a><br>"&CHR(10))
rs2.movenext
wend
Response.Write("</div>"&CHR(10))
end if
rs2.close
set rs2=nothing
i=i+1
rs.movenext
wend
end if
rs.close
set rs=nothing
Response.Write("<script language=""javascript"" type=""text/javascript"">"&CHR(10))
Response.Write("function startmenu()"&CHR(10)&"{"&CHR(10)&ljh_temp&"}"&CHR(10))
Response.Write(ljh_temp2)
Response.Write("</script>")
%>
本文介绍了一种使用ASP实现的二级树形菜单结构,通过动态生成HTML代码来展示多级菜单,并采用JavaScript控制子菜单的显示与隐藏。该方法适用于需要创建具有良好交互性的导航菜单的网站。
196

被折叠的 条评论
为什么被折叠?



