演示:http://asp2004.net/temp/treemenu/menu.asp
源代码下载:http://asp2004.net/temp/treemenu.rar
<
!
--
#include file
=
"
conn.asp
"
-->
< %
Dim Str
Function menu(id)
Set rs = server. CreateObject ( " adodb.recordset " )
sql = " select * from menu where id1= " & id & " order by url,id"
rs.Open sql, conn, 1 , 1
Str = Str + " <table border='0' cellspacing='0' cellpadding='0'> " + Chr ( 13 )
i = 1
While Not rs.EOF
ChildCount = conn. Execute ( " select count(*) from menu where id1= " & rs( " id " ))( 0 )
If ChildCount = 0 Then
If i = rs.recordcount Then
menutype = " file1"
Else
menutype = " file"
End If
menuname = " <a href=' " & rs( " url " ) & " ' target='_blank'> " & rs( " menuname " ) & " </a>"
onmouseup = " "
Else
If i = rs.recordcount Then
menutype = " menu3"
listtype = " list1"
onmouseup = " onMouseUp=change1('a " & rs( " id " ) & " ','b " & rs( " id " ) & " ');"
Else
menutype = " menu1"
listtype = " list"
onmouseup = " onMouseUp=change2('a " & rs( " id " ) & " ','b " & rs( " id " ) & " ');"
End If
menuname = rs( " menuname " )
End If
Str = Str + " <tr><td id='b " & rs( " id " ) & " ' class=' " & menutype & " ' " & onmouseup & " > " & menuname & " </td></tr> " + Chr ( 13 )
If ChildCount > 0 Then
Str = Str + " <tr id='a " & rs( " id " ) & " ' style='display:none'><td class=' " & listtype & " '> " + Chr ( 13 )
menu(rs( " id " ))
Str = Str + " </td></tr> " + Chr ( 13 )
End If
rs.movenext
i = i + 1
Wend
Str = Str + " </table> " + Chr ( 13 )
rs.Close
Set rs = Nothing
End Function
menu( 0 )
Set fso = server. CreateObject ( " scripting.filesystemobject " )
Set f1 = fso.OpenTextFile(server.MapPath( " demo.htm " ), 2 , true )
f1.Write( " <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'> " )
f1.Write( " <html> " )
f1.Write( " <head> " )
f1.Write( " <meta http-equiv='Content-Type' content='text/html; charset=gb2312'> " )
f1.Write( " <title>哈哈~~~!这回速度超快了吧?</title> " )
f1.Write( " <meta name='keywords' content='asp2004,树,菜单,无限级'> " )
f1.Write( " <meta name='author' content='小灰,quxiaohui_0@163.com'> " )
f1.Write( " <link href='style.css' rel='stylesheet' type='text/css'> " )
f1.Write( " <script language='javascript' src='function.js'></script> " )
f1.Write( " </head> " )
f1.Write( " <body> " )
f1.Write( " <a href='http://asp2004.net' target='_blank'>http://asp2004.net</a>提供最新下载《<a href='menu.asp'>管理</a>》<br> " )
f1.Write(Str)
f1.Write( " </body> " )
f1.Write( " </html> " )
f1.Close
Set fso = Nothing
response.Redirect( " demo.htm " )
% >
< %
Dim Str
Function menu(id)
Set rs = server. CreateObject ( " adodb.recordset " )
sql = " select * from menu where id1= " & id & " order by url,id"
rs.Open sql, conn, 1 , 1
Str = Str + " <table border='0' cellspacing='0' cellpadding='0'> " + Chr ( 13 )
i = 1
While Not rs.EOF
ChildCount = conn. Execute ( " select count(*) from menu where id1= " & rs( " id " ))( 0 )
If ChildCount = 0 Then
If i = rs.recordcount Then
menutype = " file1"
Else
menutype = " file"
End If
menuname = " <a href=' " & rs( " url " ) & " ' target='_blank'> " & rs( " menuname " ) & " </a>"
onmouseup = " "
Else
If i = rs.recordcount Then
menutype = " menu3"
listtype = " list1"
onmouseup = " onMouseUp=change1('a " & rs( " id " ) & " ','b " & rs( " id " ) & " ');"
Else
menutype = " menu1"
listtype = " list"
onmouseup = " onMouseUp=change2('a " & rs( " id " ) & " ','b " & rs( " id " ) & " ');"
End If
menuname = rs( " menuname " )
End If
Str = Str + " <tr><td id='b " & rs( " id " ) & " ' class=' " & menutype & " ' " & onmouseup & " > " & menuname & " </td></tr> " + Chr ( 13 )
If ChildCount > 0 Then
Str = Str + " <tr id='a " & rs( " id " ) & " ' style='display:none'><td class=' " & listtype & " '> " + Chr ( 13 )
menu(rs( " id " ))
Str = Str + " </td></tr> " + Chr ( 13 )
End If
rs.movenext
i = i + 1
Wend
Str = Str + " </table> " + Chr ( 13 )
rs.Close
Set rs = Nothing
End Function
menu( 0 )
Set fso = server. CreateObject ( " scripting.filesystemobject " )
Set f1 = fso.OpenTextFile(server.MapPath( " demo.htm " ), 2 , true )
f1.Write( " <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'> " )
f1.Write( " <html> " )
f1.Write( " <head> " )
f1.Write( " <meta http-equiv='Content-Type' content='text/html; charset=gb2312'> " )
f1.Write( " <title>哈哈~~~!这回速度超快了吧?</title> " )
f1.Write( " <meta name='keywords' content='asp2004,树,菜单,无限级'> " )
f1.Write( " <meta name='author' content='小灰,quxiaohui_0@163.com'> " )
f1.Write( " <link href='style.css' rel='stylesheet' type='text/css'> " )
f1.Write( " <script language='javascript' src='function.js'></script> " )
f1.Write( " </head> " )
f1.Write( " <body> " )
f1.Write( " <a href='http://asp2004.net' target='_blank'>http://asp2004.net</a>提供最新下载《<a href='menu.asp'>管理</a>》<br> " )
f1.Write(Str)
f1.Write( " </body> " )
f1.Write( " </html> " )
f1.Close
Set fso = Nothing
response.Redirect( " demo.htm " )
% >