ASP cascade menu

Source: Internet
Author: User

<% @ Language = "VBScript" codePage = "936" %>
<! -- # Include file = "Connections/connmenu. asp" -->

<! -- Open two tables -->
<%
Set RS1 = server. Createobject ("ADODB. recordset ")
Sql1 = "select * from main"
Rs1.open sql1, mm_connmenu_string, 1, 3
Set rs2 = server. Createobject ("ADODB. recordset ")
Sql2 = "select * From sub"
Rs2.open sql2, mm_connmenu_string, 1, 3

%>
<Form name = "form1">
<! -- Create menu 1 -->
<Select name = "mainmenu" size = "1" onchange = "Redirect (this. Options. Value)">
<Option value = 0> select ...... </Option>
<% While not rs1.eof %>
<Option value = "<% = RS1 (" main_id ") %>"> <% = RS1 ("main_name") %> </option>
<% Rs1.movenext
Wend %>
</SELECT>
<! -- Create menu 2 -->
<Select name = "submenu" size = "1">
<Option value = 0> select </option>
</SELECT>

</Form>
<! -- The following is a specific script statement -->
<SCRIPT>
<! --

VaR temp = Document. form1.submenu
Function redirect (x ){

VaR I
I = 0
For (var m = temp. Options. Length-1; m> 0; m --)
Temp. Options [m] = NULL

<% While not rs2.eof
%>
CNT = <% = rs2 ("main_id") %>

If (CNT = x ){
Temp. Options [I] = New Option ("<% = rs2 (" sub_name ") %>", "<% = rs2 (" sub_id ") %> ")
I = I + 1}
<%
Rs2.movenext
Wend %>

}

// -->
</SCRIPT>

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.