The key code part of ASP to realize infinite level directory number

Source: Internet
Author: User
Tags end eval key sql
ASP implementation of the key code for unlimited number of directory parts

<%
Set Conn=server.createobject ("ADODB. CONNECTION ")
Connstr= "dbq=" +server.mappath ("Db1.mdb") + ";D efaultdir=;D river={microsoft Access DRIVER (*.mdb)};"
Conn.Open ConnStr
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
If Rs.recordcount=0 Then
Rs.close
Set rs=nothing
Exit function
End If
Response.Write ("<table border= ' 0 ' cellspacing= ' 0 ' cellpadding= ' 0 ' >")
I=1
While not rs.eof
If Len (rs ("url")) >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= ' With (eval (' id ' &rs (' IDs ') & ') if (style.display== ') {style.display= ' none '; This.classname= ' Menu3 ';} Else{style.display= '; this.classname= ' Menu4 ';}
Else
Menutype= "Menu1"
Listtype= "List"
Onmouseup= ' With (eval (' id ' &rs (' IDs ') & ') if (style.display== ') {style.display= ' none '; This.classname= ' Menu1 ';} Else{style.display= '; This.classname= ' m

Enu2 ';} '
End If
Menuname=rs ("Menuname")
End If
%>
<tr>
&LT;TD class= "<%= menutype%>" onmouseup= "<%= onmouseup%>" ><%= menuname%></td>
</tr>
<%if Len (rs ("url")) <3 then%>
<tr id= "id<%= RS (" id ")%>" style= "Display:none" >
&LT;TD class= "<%= listtype%>" ><%menu (RS ("id")%></td>
</tr>
<%
End If
Rs.movenext
I=i+1
Wend
Response.Write ("</table>")
Rs.close
Set rs=nothing
End Function
%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title>========= infinite-level directory tree =========http://www.webjx.com</title>
<style type= "Text/css" >
<!--
. menu1 {
Background-image:url (folder1.gif);
Background-repeat:no-repeat;
height:17px;
left:32px;
padding-left:32px;
Cursor:hand;
}
. menu2 {
Background-image:url (folder2.gif);
Background-repeat:no-repeat;
height:17px;
left:32px;
padding-left:32px;
Cursor:hand;
}
. menu3 {
Background-image:url (folder3.gif);
Background-repeat:no-repeat;
height:17px;
left:32px;
padding-left:32px;
Cursor:hand;
}
. menu4 {
Background-image:url (fo
Lder4.gif);
Background-repeat:no-repeat;
height:17px;
left:32px;
padding-left:32px;
Cursor:hand;
}
. list {
padding-left:20px;
Background-image:url (list.gif);
Background-repeat:repeat-y;
}
. list1 {
padding-left:20px;
}
. file {
Background-image:url (file.gif);
Background-repeat:no-repeat;
height:16px;
Cursor:hand;
padding-left:32px;
}
. file1 {
Background-image:url (file1.gif);
Background-repeat:no-repeat;
height:16px;
Cursor:hand;
padding-left:32px;
}
Body {
font-size:9pt;
Color: #000000;
Background-color: #FFFFFF;
}
a:link {
font-size:9pt;
Color: #000000;
Text-decoration:none;
}
a:visited {
font-size:9pt;
Color: #000000;
Text-decoration:none;
}
a:hover {
font-size:9pt;
Color: #0000FF;
Text-decoration:none;
position:relative;
right:1px;
bottom:1px;
}
a:active {
font-size:9pt;
Color: #000000;
Text-decoration:none;
}
-->
</style>
<body>
<a href= "http://www.webjx.com/" target= "_blank" >http://www.webjx.com/</a> offers the latest downloads <a href= "menu.asp" > Management </a> "<br>
<%
Menu 0
Conn.close
Set conn=nothing
%>y>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.