A recursive code that generates a tree-like menu that works like Windows Explorer

Source: Internet
Author: User
Tags chr trim
window| Menu | recursion <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=http://www.163design.net/a/y/"Minus.gif";
}

Else
{ss.style.display= "none";
Aa.style.display= "None";
ii.src=http://www.163design.net/a/y/"Http://www.163design.net/a/y/plus.gif";}
}

function Onlyclose (SS,II,AA)
{
Ss.style.display= "None";
Aa.style.display= "None";
ii.src=http://www.163design.net/a/y/"Http://www.163design.net/a/y/plus.gif";
}
</SCRIPT>
</HEAD>
<body bgcolor= #99CCFF >
<%
Dim dbconn
Dim Idindex

Idindex = 0

' Establish a database connection
Set dbconn = Server.CreateObject ("Adodb.connection")
Dbconn.open "Driver={microsoft Access DRIVER (*.mdb)}; Dbq= "& Server.MapPath (" Test.mdb ")

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Generate recursive function of file type tree, passed in parameter: Nowitem as tree Node ID '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Doitem (Nowitem)
Dim rstest
Dim Youngerbrother ' ID of the next sibling node
Dim Olderson ' The ID of the first word node

' Set up a recordset
Set rstest = Server.CreateObject ("Adodb.recordset")

' Generate SQL statements, manipulate doc_typetree tables
strSQL = "SELECT * from tab_test where ID = '" & Nowitem & "'"

' Generate a Recordset
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") & "")

' Show child nodes
If Olderson = "" or Olderson = "then" When this item has no subkeys, output the corresponding code
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. Show the contents of this item
Response.Write "<TR>" & Chr (10)
Response.Write "<td language=jscript Onmouseup=turnit (" & _
"Content" & Idindex & "," & _
"img" & Idindex & "," & _
"Aux" & Idindex & ");>" & Chr (10)
Response.Write " '" & 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. Export Descendants Tree Header code
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. Output descendants Tree code
Call Doitem (Olderson)

' *4. Output descendants tree Tail code
Response.Write "</TABLE>"
Response.Write "</TD>" & Chr (10)
Response.Write "</TR>" & Chr (10)
End If

If Youngerbrother <> "" and Youngerbrother <> "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>



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.