欢迎光临
我们一直在努力

一段递归生成类似Windows资源管理器一样效果的树状菜单的代码

建站超值云服务器,限时71元/月

<html>

<head>

<meta content="text/html; charset=gb2312" http-equiv=content-type>

<script lanuage="jscript">

function turnit(ss,ii,aa)

{

if (ss.style.display=="none")

{ss.style.display="";

aa.style.display="";

ii.src="minus.gif";

}

else

{ss.style.display="none";

aa.style.display="none";

ii.src="plus.gif";}

}

function onlyclose(ss,ii,aa)

{

ss.style.display="none";

aa.style.display="none";

ii.src="plus.gif";

}

</script>

</head>

<body bgcolor=#99ccff>

<%

dim dbconn

dim idindex

idindex = 0

建立数据库连接

set dbconn = server.createobject("adodb.connection")

dbconn.open "driver={microsoft access driver (*.mdb)}; dbq=" & server.mappath ("test.mdb")

生成文件类型树的递归函数,传入参数:nowitem为树节点的id

sub doitem(nowitem)

dim rstest

dim youngerbrother 下一个兄弟节点的id

dim olderson 第一个字节点的id

建立记录集

set rstest = server.createobject("adodb.recordset")

生成sql语句,操作doc_typetree表

strsql = "select * from tab_test where id = " & nowitem & ""

生成记录集

rstest.open strsql,dbconn,1,3

if rstest.eof then

rstest.close

set recdostype = nothing

exit sub

end if

youngerbrother = trim(rstest("brothernode") & "")

olderson = trim(rstest("sonnode") & "")

nodeid = trim(rstest("id") & "")

nodename = trim(rstest("nodename") & "")

显示子节点

if olderson = "" or olderson = "00" then 当此项无子项时,输出相应的代码

response.write "<tr>" & chr(10)

response.write "<td> </td>" & chr(10)

response.write "<td>"

response.write "<a href=test>" & nodename & "</a>"

response.write "</td>" & chr(10)

response.write "</tr>" & chr(10)

else

*1.显示本项内容

response.write "<tr>" & chr(10)

response.write "<td language=jscript onmouseup=turnit(" & _

"content" & idindex & "," & _

"img" & idindex & "," & _

"aux" & idindex & ");>" & chr(10)

response.write "<img height=9 id=img" & idindex & " src=plus.gif width=9>" & chr(10)

response.write "</td>" & chr(10)

response.write "<td>" & chr(10)

response.write "<a href=frame_4_publish.asp?doctypeid=" & _

nodeid & " target=frmfour>" & nodename & _

"</a>" & chr(10)

response.write "</td>" & chr(10)

response.write "</tr>" & chr(10)

*2.输出子孙树头代码

response.write "<tr>" & chr(10)

response.write "<td id=aux" & idindex & " style=display: none> </td>" & chr(10)

response.write "<td id=content" & idindex & " style=display: none>" & chr(10)

response.write "<table border=0>"

idindex = idindex + 1

*3.输出子孙树代码

call doitem(olderson)

*4.输出子孙树尾代码

response.write "</table>"

response.write "</td>" & chr(10)

response.write "</tr>" & chr(10)

end if

if youngerbrother <> "" and youngerbrother <> "00" then

call doitem(youngerbrother)

end if

rstest.close

set rstest = nothing

end sub

response.write "<table border=0>"

call doitem("01")

response.write "</table>"

dbconn.close

set dbconn = nothing

%>

</body>

</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 一段递归生成类似Windows资源管理器一样效果的树状菜单的代码
分享到: 更多 (0)