Similar to the implementation of the left navigation tree of MSDNCSDN! [& #106 avascript + ASP]

Source: Internet
Author: User
The effects of the left navigation tree of MSDN and CSDN are that when you click the parent node, a request is sent to fill its subnodes! It seems that the webpage only refreshes parts! JavaScript + [asp + Access] source code download: www.triaton.com.cnPrivateZipTree.zip! -- Tree. asp --! DOCTYPEHTMLPUBLIC-W3CDTDHTML

The effects of the left navigation tree of MSDN and CSDN are that when you click the parent node, a request is sent to fill its subnodes! It seems that the webpage only refreshes parts! JavaScript + [asp + Access] realize source program download: http://www.triaton.com.cn/Private/Zip/Tree.zip! -- Tree. asp --! Doctype html public-// W3C // DTD HTML

MSDN and CSDNLeftNavigationTreeEffectWhen you click the parent node, send a request to fill in its child nodes! It seems that the webpage only refreshes parts! JavaScript + [asp + Access]Implementation

Source program download: http://www.triaton.com.cn/Private/Zip/Tree.zip





New Document







Script
Function ExpandNode (ParentNode, ParentId ){
Var NodeX = eval (ParentNode. id + _ 0 );
If (NodeX. style. display = none)
{
NodeX. style. display = block;
If (NodeX. loaded = no)
{
Document. frames [hiddenframe]. location. replace (http: // localhost/dvbbs/subtree. asp? PID = + ParentId + & PNode = + ParentNode. id );
NodeX. loaded = yes;
}
}
Else
{
NodeX. style. display = none;
}
}
Script






      

          



                               

<%
Dim adoConnection
Set adoConnection = Server. CreateObject (ADODB. Connection)
AdoConnection. Open Provider = SQLOLEDB.1; Persist Security Info = False; User ID = sa; Initial Catalog = Test; Data Source = TRIATON \ PSQL2KE
AdoConnection. Open Provider = Microsoft. Jet. OLEDB.4.0; Data Source = & Server. mappath (/dvbbs) & \ Tree. mdb; Persist Security Info = False
Dim adoRecordset
Set adoRecordset = Server. CreateObject (ADODB. Recordset)
AdoRecordset. Open select *, (select count (*) from tree where parentid = T. id) as children from tree T where rootid = id, adoConnection
Dim I
I = 0
Do until adoRecordset. eof
%>

>
<% If adoRecordset. Fields. item (Children). value> 0 then %>
OnClick = ExpandNode (Node _ <% = I %>, <% = adoRecordset. Fields. item (id). value %>)> +
<% Else %>
>-
<% End if %>
, <% = AdoRecordset. Fields. item (id). value %>)> <% = adoRecordset. Fields. item (remark). value %>


_ 0> loading...
  


<% I = I + 1
AdoRecordset. MoveNext
Loop
AdoRecordset. close
Set adoRecordset = nothing
AdoConnection. close
Set adoConnection = nothing
%>
         

    
  







New Document






<%
Dim parentid
Parentid = request. querystring (PID)
Parentnode = request. querystring (Parentnode)
Dim adoConnection
Set adoConnection = Server. CreateObject (ADODB. Connection)
AdoConnection. Open Provider = SQLOLEDB.1; Persist Security Info = False; User ID = sa; Initial Catalog = Test; Data Source = TRIATON \ PSQL2KE

AdoConnection. Open Provider = Microsoft. Jet. OLEDB.4.0; Data Source = & Server. mappath (/dvbbs) & \ Tree. mdb; Persist Security Info = False
Dim adoRecordset
Set adoRecordset = Server. CreateObject (ADODB. Recordset)
AdoRecordset. Open select *, (select count (*) from tree where parentid = T. id) as Children from tree T where parentid = & parentid, adoConnection
Response. write adoRecordset. source
Dim I
Dim SHTML
Dim parentnode
Parentnode = request. querystring (Pnode)
Dim j
J = len (parentnode)-len (replace (parentnode ,_,))
Dim nSpace
For I = 0 to j-1
NSpace = nSpace +
Next
I = 0
Do until adoRecordset. eof
Shtml = shtml _
&

& Amp; nSpace _
& If adoRecordset. Fields. item (Children). value> 0 then
Shtml = shtml & onClick = ExpandNode (& parentnode & _ & I + 1 &, & adoRecordset. Fields. item (id). value &)> +
Else
Shtml = shtml &>-
End if
Shtml = shtml & \ n & if adoRecordset. Fields. item (Children). value> 0 then
Shtml = shtml & onDblClick = ExpandNode (& parentnode & _ & I + 1 &, & adoRecordset. Fields. item (id). value &)
End if
Shtml = shtml &> & adoRecordset. Fields. item (id). value &: & adoRecordset. Fields. item (remark). value &


If adoRecordset. Fields. item (Children). value> 0 then
Shtml = shtml &

End if
I = I + 1
AdoRecordset. MoveNext
Loop
AdoRecordset. close
Set adoRecordset = nothing
AdoConnection. close
Set adoConnection = nothing
Response. write shtml
%>
Script
Var x = eval (parent. + <% = request. querystring (Pnode) & _ 0%> );
X. innerHTML = <% = shtml %>;
Script

Table Structure:
Tree (id, parentid, remark)

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.