Online Three-level menu is much more but the code is more annoying, I should say this is more intuitive:
' must be connected to the database first, needless to say.
' Database structure
' Category 1 Table name: A field: Id,name Description: ID The primary key is the ID value of category 1, name is Category 1
' Category 2 Table name: AA field: Id,aid,name Description: ID PRIMARY key is the ID value of category 2, AID is the ID value of category 1, name is Category 2
' Category 3 Table name: AAA field: Id,aid,aaid,name Description: ID primary key is Category 3 ID value, AID is the ID value of category 1, Aaid is the ID value of category 2, name is Category 3
=====test1.asp You can test, you receive the ID value of the category = =
<%
Response.Write "1:" &request.form ("S1") & "<BR>"
Response.Write "2:" &request.form ("S2") & "<BR>"
Response.Write "3:" &request.form ("S3") & "<BR>"
%>
Copy Code code as follows:
<!--Level Three linkage menu starts-->
<script language= "JavaScript" >
<!--
<%
' Level two data saved to array
Dim Count2,rsclass2,sqlclass2
Set Rsclass2=server.createobject ("Adodb.recordset")
Sqlclass2= "SELECT * from AA"
Rsclass2.open sqlclass2,conn,1,1
%>
var subval2 = new Array ();
Array structure: First level root value, level two root value, level two display value
<%
Count2 = 0
Do as not rsclass2.eof
%>
SUBVAL2[<%=COUNT2%>] = new Array (' <%=rsclass2 ("AID")%> ', ' <%=rsclass2 ("ID")%> ', ' <%=rsclass2 (" Name ")%> ')
<%
Count2 = Count2 + 1
Rsclass2.movenext
Loop
Rsclass2.close
%>
<%
' Level three data saved to array
Dim COUNT3,RSCLASS3,SQLCLASS3
Set Rsclass3=server.createobject ("Adodb.recordset")
Sqlclass3= "SELECT * from AAA"
Rsclass3.open sqlclass3,conn,1,1
%>
var subval3 = new Array ();
Array structure: Level Two root, level three root, level three display value
<%
Count3 = 0
Do as not rsclass3.eof
%>
SUBVAL3[<%=COUNT3%>] = new Array (' <%=rsclass3 ("Aaid")%> ', ' <%=rsclass3 ("ID")%> ', ' <%=RSCLASS3 ( "Name")%> ')
<%
Count3 = Count3 + 1
Rsclass3.movenext
Loop
Rsclass3.close
%>
function Changeselect1 (LocationID)
{
document.form1.s2.length = 0;
Document.form1.s2.options[0] = new option (' = = Please select category = = ', ');
document.form1.s3.length = 0;
Document.form1.s3.options[0] = new option (' = = Please select topic = = ', ');
for (i=0; i<subval2.length; i++)
{
if (subval2[i][0] = = LocationID)
{Document.form1.s2.options[document.form1.s2.length] = new Option (subval2[i][2],subval2[i][1]);
}
}
function Changeselect2 (LocationID)
{
document.form1.s3.length = 0;
Document.form1.s3.options[0] = new option (' = = Please select topic = = ', ');
for (i=0; i<subval3.length; i++)
{
if (subval3[i][0] = = LocationID)
{Document.form1.s3.options[document.form1.s3.length] = new Option (subval3[i][2],subval3[i][1]);
}
}
-->
</script>
<form name= "Form1" method= "Post" action= "test1.asp" >
Three-level linkage:
<%
Dim Count1,rsclass1,sqlclass1
Set Rsclass1=server.createobject ("Adodb.recordset")
Sqlclass1= "SELECT * from a"
Rsclass1.open sqlclass1,conn,1,1
%>
<select name= "S1" onchange= "Changeselect1 (this.value)" >
<option>== Please select Channel ==</option>
<%
Count1 = 0
Do as not rsclass1.eof
Response.Write "<option value=" &rsclass1 ("ID") & ">" &rsclass1 ("Name") & "</option>"
Count1 = count1 + 1
Rsclass1.movenext
Loop
Rsclass1.close
%>
</select>
<select name= "S2" onchange= "Changeselect2 (this.value)" >
<option>== Please select a category ==</option>
</select>
<select name= "S3" >
<option>== Please select the topic ==</option>
</select>
<input type= "Submit" name= "Submission" value= "submitted" ></form>
<!--level Three linkage menu end-->