Implementation of tree structure (II.)

Source: Internet
Author: User
Tags execution split
Tree type Structure implementation of tree structure (Part II)
Author: ACE Last updated: 06/08/2000 Category: Original

In the previous section, we discussed how to read data and get a result set that represents a hierarchical relationship. In this section, let's look at how to implement an MSDN-like interface in scripting languages.

This functionality can be done on the server side as well as on the client, which depends on the need. The server-side completion requires the processing time of the server and related resources, the client is required to support scripting language (usually JavaScript), and to download the execution script.

In our example, we use the method of client-side script execution.

1. Send data to the browser

Look at the following code:

Dim getrsstring
Dim CNN
Dim RS
Dim l_id
l_id = "1" ' means root node

Set CNN = Server.CreateObject ("ADODB.") Connection ")
Set rs = Server.CreateObject ("ADODB.") RecordSet ")
Cnn. Open "Provider=sqloledb ................ Slightly
Rs. Open "Sp_listfile" & L_ID,CNN

getrsstring = Rs. GetString (2,, "quot;", "~ ~") ' adClipString
Rs. Close
Set rs = Nothing
Cnn. Close
Set cnn = Nothing

Response.Write "<form id= ' rs ' name= ' rs ' >" &_
"<input type= ' hidden ' id= ' rscache ' name= '" Rscache ' value= ' "" & Getrsstring & "' ></FORM>" &_
"<script language=javascript src= ' listfile.js ' ></SCRIPT>" &_
"<script language=javascript>loadrecords (" + l_id + ");</script>"

In the code above, a string separated by a quot and ~ ~ is obtained using the GetString method, and is stored with a hidden form. The Listfile.js script implements what we want, and Loadrecords is one of those functions.

2. Scripts in Listfile.js

This is all code:

function Toggledisplay (Obutton, Oitems)
{
if ((OItems.style.display = "") | |    (OItems.style.display = = "None")) {
OItems.style.display = "block";
OBUTTON.SRC = BOOK_OPEN.SRC;
} else {
OItems.style.display = "None";
OBUTTON.SRC = BOOK_CLOSE.SRC;
}

}
function Loadrecords (l_id) {
var strrecords=document.all ("Rscache"). Value;
var arrrecords=strrecords.split ("~ ~");
var arrfields;
var current_level;
var current_id;
var strtemp;
var strlist;
var prior_id;
var prior_level=-1;
var i;
var J;
prior_id=l_id;
Strlist = "<table><tr><td height=300 valign=top class=newscontents><!--" + L_ID + "-->";
for (i=0;i<arrrecords.length;i++)
{
Arrfields=arrrecords[i].split ("? quot;");
Current_level = Arrfields[0];
current_id = arrfields[1];
if (arrfields[2] = = 0)
{
strtemp = "<div><img src= ' http://www.163design.net/a/q/images/plus.gif ' id= ' i_" + current_id +
"' Position:relative;left:" + (CURRENT_LEVEL*17) +
&nb



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.