Menu | program | Web page
ASP General program for folding menus in Web pages
Bank of China Shanxi province Jincheng Branch Science and Technology Branch
Yuan Jin Yu
With the increasing popularity of internet/intranet, Web programming and Web page production have become a trend. This article introduces the reader to a Web page to realize the Folding menu programming technology, I believe it will give you a lot of color. The so-called folding menu is actually a dynamically displayed menu, that is, when the menu is not in operation, only show the main menu, when a menu item is selected, its subordinate submenu dynamically displayed, the choice is completed, and hidden.
Implementation Principle
Presumably we are very familiar with the HTML <DIV> tag, we use its Display property to let the <DIV> tag content hidden or displayed, specifically, when the display is set to "none" hidden, set to "" display. If we have already marked all the menu names (including submenus) with <DIV>, we can implement the folding menu by dynamically controlling the menu options shown or hidden using the ASP language and script scripts.
The question now is how to add a menu item name to a program, and of course you can add it directly to the Web page, but if you change the menu option, you have to alter the control code of the page, which is clearly not sensible. This article uses all the menu option names in a certain format in a text file, in the Web page load, the ASP code automatically read its contents, so if you change the menu options, as long as the corresponding changes in this file.
Regarding the file operation, we use the ASP built-in file access component to complete, the concrete usage sees the article The program code.
Menu Text File
This article contracts the contents of the menu text file to conform to the following rules: The name of a menu option must have three rows (see the following example); a blank line is not allowed in a file; a menu option name can have spaces before it, but it must be formed with the SPACEBAR (space), and you cannot use the TAB key; end of file with two lines of "*end*" To complete.
Suppose the next level three menu:
Operating system software
Computer software----Application System software
Tool Software-----PC tools
CuteFTP
The menu text should be in the following format:
1------Represents the 1th main course single-name
Computer software--------Menu name (hereinafter)
3 If not 0, specify the number of submenus in this menu; This example is 3
1*1 represents the 1th submenu of the 1th main menu (must use the * number)
Operating system software
0 http://... if the---------is 0, the menu item does not have a submenu followed by the hyperlink URL
1*2----------represents the 2nd submenu of the 1th Main Menu (hereinafter)
Application System software
0 http://...
1*3
Tool Software
2
1*3*1--------The 1th submenu of the 3rd submenu in the 1th main menu
PC TOOLS
0 http://...
Program Code:
<HTML>
<HEAD>
<script language= "VBScript" >
' Show or hide submenus
Sub Disp_sub_menu (Curid)
Dim ct,i,tmpid
Ct=document.all (Curid). Style.ct
I=1
While I<=cint (CT)
Tmpid=curid+ "*" +cstr (i)
If document.all (tmpid). style.display= "None" Then
document.all (tmpid). style.display= ""
Else
document.all (tmpid). style.display= "None"
If CInt (document.all (tmpid). Style.ct) >0 Then
If document.all (tmpid+ "*1"). style.display= "" Then
Disp_sub_menu (tmpid) ' recursively calls subordinate submenus
End If
End If
End If
I=i+1
Wend
End Sub
</SCRIPT></HEAD><BODY>
<font color=red>