ASP+ACCESS实现的无限级目录树

下载地址: http://www.knowsky.com/download/treemenu.rar

关键代码:

 1   
 2set conn=server.createobject("ADODB.CONNECTION")   
 3connstr="DBQ="+server.mappath("db1.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"   
 4conn.open connstr   
 5function menu(id)   
 6set rs=server.CreateObject("adodb.recordset")   
 7sql="select * from menu where id1="&id&" order by url,id"   
 8rs.open sql,conn,1,1   
 9if rs.recordcount=0 then   
10rs.close   
11set rs=nothing   
12exit function   
13end if   
14response.write("

<table border="0" cellpadding="0" cellspacing="0">")
i=1
while not rs.eof
if len(rs("url"))&gt;0 then
if i=rs.recordcount then
menutype="file1"
else
menutype="file"
end if
menuname="<a href='"&amp;rs("url")&amp;"' target="_blank">"&amp;rs("menuname")&amp;"</a>"
onmouseup=""
else
if i=rs.recordcount then
menutype="menu3"
listtype="list1"
onmouseup="with(eval('id"&amp;rs("id")&amp;"'))if(style.display==''){style.display='none';this.className='menu3';}else{style.display='';this.className='menu4';}"
else
menutype="menu1"
listtype="list"
onmouseup="with(eval('id"&amp;rs("id")&amp;"'))if(style.display==''){style.display='none';this.className='menu1';}else{style.display='';this.className='menu2';}"
end if
menuname=rs("menuname")
end if

1<tr>
2<td class="``` = menutype ```" onmouseup="```
3= onmouseup
4```">```
5= menuname
6```</td>
7</tr>   

if len(rs("url"))&lt;3 then

1<tr ```"="" id="id```
2= rs(" id")="" style="display:none">
3<td class="``` = listtype ```">```
4menu(rs("id"))
5```</td>
6</tr>   

end if
rs.movenext
i=i+1
wend
response.write("</table>

1")   
2rs.close   
3set rs=nothing   
4end function   
 1<html>
 2<head>
 3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 4<title>=========无限级目录树=========http://www.knowsky.com</title>
 5<style type="text/css">   
 6<!--   
 7.menu1 {   
 8background-image: url(folder1.gif);   
 9background-repeat: no-repeat;   
10height: 17px;   
11left: 32px;   
12padding-left: 32px;   
13cursor: hand;   
14}   
15.menu2 {   
16background-image: url(folder2.gif);   
17background-repeat: no-repeat;   
18height: 17px;   
19left: 32px;   
20padding-left: 32px;   
21cursor: hand;   
22}   
23.menu3 {   
24background-image: url(folder3.gif);   
25background-repeat: no-repeat;   
26height: 17px;   
27left: 32px;   
28padding-left: 32px;   
29cursor: hand;   
30}   
31.menu4 {   
32background-image: url(folder4.gif);   
33background-repeat: no-repeat;   
34height: 17px;   
35left: 32px;   
36padding-left: 32px;   
37cursor: hand;   
38}   
39.list {   
40padding-left: 20px;   
41background-image: url(list.gif);   
42background-repeat: repeat-y;   
43}   
44.list1 {   
45padding-left: 20px;   
46}   
47.file {   
48background-image: url(file.gif);   
49background-repeat: no-repeat;   
50height: 16px;   
51cursor: hand;   
52padding-left: 32px;   
53}   
54.file1 {   
55background-image: url(file1.gif);   
56background-repeat: no-repeat;   
57height: 16px;   
58cursor: hand;   
59padding-left: 32px;   
60}   
61body {   
62font-size: 9pt;   
63color: #000000;   
64background-color: #FFFFFF;   
65}   
66a:link {   
67font-size: 9pt;   
68color: #000000;   
69text-decoration: none;   
70}   
71a:visited {   
72font-size: 9pt;   
73color: #000000;   
74text-decoration: none;   
75}   
76a:hover {   
77font-size: 9pt;   
78color: #0000FF;   
79text-decoration: none;   
80position: relative;   
81right: 1px;   
82bottom: 1px;   
83}   
84a:active {   
85font-size: 9pt;   
86color: #000000;   
87text-decoration: none;   
88}   
89\-->   
90</style>
91</head>
92<body>
93<a href=" http://www.knowsky.com/ " target="_blank">http://www.knowsky.com/</a>提供最新下载《<a href="menu.asp">管理</a>》<br/>   

menu 0
conn.close
set conn=nothing

1</body>
2</html>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus