Follow me to make a tree menu (i)

Source: Internet
Author: User
menu and I learn to do tree menu (a)
Keywords: asp|-tree Menu | recursive
It's written in front.
In the Web page, in order to facilitate the organization of content, often used to the number of menus, with a tree-shaped dishes
Single (effect see Http://www.he-xi.com/tree), can be very square
To organize complex content. such as the classification of goods, the classification of downloaded files, website navigation, etc.
Wait This is one of those things to solve here. We'll use the database to store the tree-type menu knot.
structure, and input with ASP program.

(i) Functional design
The tree menu does not require much of a functional design. Only the record of the increase, delete, change. And also
Is the most basic, but also the most important display function. The display feature is to display the records and to
Organize the displayed content into a Dynamic Web page for the client. can also join the mobile function, the realization of the time
It may be a bit complicated, here I do not specifically write out, interested friends can write their own. It's OK
Extended Administrator Login function, only admin login can be managed, no login only show
Menu. Other features need to be updated, not listed here. The specific function design is as follows:
1, display menu: The most basic is the most important function. Displays menus and organizes them into dynamic Web pages for the client.
2, increase the record: Add a record, as the selected record of the submenu.
3, delete the record: Delete the selected records.
4, modify the record: Modify the selected record. The properties that can be modified are: Name, link.
5, * Mobile record: The selected records are moved to the specified record, to become its submenu.
6, * Admin login: Only after login can be managed.
7, stored content: Each record to store the menu name and menu link.

Note: The addition of * is not implemented in this article.

(ii) Database design
The database uses an Access 2000 database. Database file for Tree.mdb If security is required, you can
Renamed to Tree.asp but remember to do the corresponding changes in the ASP program. The database structure is as follows:
Table Name: Treemenu
Field Name Segment type description
ID Auto Number/indexed no repeat/increment number of each record
par_id long/indexed with duplicate parent Node ID number/0 for root
chi_id Long Integer/indexed with duplicate sub-nodes
TXT text/Length 50 menu name/50 too little to change yourself
Link text/Length 50 link/50 too little to change yourself

When you create a new data table, enter a record, par_id and chi_id are 0 other arbitrary

(iii) Document design
Here only as a demo, and not to add too many features. So there's only one file. The name is index.asp
To be placed in the folder as the default document. Here you will use some images to indicate the state of the menu and open the resource
Browser, expand some folders, and then grab a picture and edit it. Be aware that the resulting image is best in the same size.
We use 16x16 images in our text. You can download it directly here:
Http://www.he-xi.com/tree/images.zip


(d) Related functions
Basically the functions to be used are the same as "I learn to do a message this" article. is primarily used to manipulate databases. In
Here's another list:
Shared function file, filename: operation$db.asp
<%
'*******************************************************************
' Common Database ASP functions
'*******************************************************************
' Database constants
Databasename= "Tree.mdb" database name, if renamed, modify the line here
'*******************************************************************
' Open the Database
Sub Opendb (Connect)
Set Connect=server. CreateObject ("Adodb.connection")
Connect. connectionstring= "Driver={microsoft Access DRIVER (*.mdb)}; Dbq= "&_
Server. MapPath (DatabaseName)
Connect. Open strconn
End Sub
'*******************************************************************
' Close the database
Sub Closedb (Connect)
Connect.close
Set connect=nothing
End Sub
'*******************************************************************
' Open a single table read
Sub OpenTable (connect,tbname,myrs)
Set Myrs=server.createobject ("Adodb.recordset")
Rssql= "SELECT * from" & Tbname
Myrs.open rssql,connect,1,1
End Sub
'*******************************************************************
' Close temporary table
Sub CloseTable (RS)
Rs.close
Set rs=nothing
End Sub
'*******************************************************************
' Querying the Database
Sub Searchtable (CONNECT,SQL,RS)
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open sql,connect,1,1
End Sub

'*******************************************************************
' Query and change the database
Sub Changetable (CONNECT,SQL,RS)
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open sql,connect,1,3
End Sub

'*******************************************************************
' Display information for debugging
Sub W (msg)
Response.Write msg
End Sub

'*******************************************************************
' Program interrupts for debugging
Sub Userstop ()
Response.End
End Sub
%>



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.