<%
'OK studio http://ok123.k989.com
'Sort level-1 Classification Table: sort_id, sort_name
'Nsort level-2 Classification Table: nsort_id, sort_id, nsort_name
'Nsort Level 3 Classification Table: nnsort_id, nsort_id, nnsort_name
%>
<! -- # Include file = "conn. asp" -->
<%
Dim count
Set rs = server. Createobject ("ADODB. recordset ")
SQL = "select * From nsort"
Rs. Open SQL, Conn, 1, 3
%>
<Script language = "JavaScript">
VaR onecount;
Onecount = 0;
Subcat = new array ();
<%
Count = 0
Do while not Rs. EOF
%>
Subcat [<% = count %>] = new array ("<% = trim (RS (" nsort_name ") %> ", "<% = trim (RS (" sort_id ") %>", "<% = trim (RS (" nsort_id ") %> ");
<%
Count = count + 1
Rs. movenext
Loop
Rs. Close
%>
Onecount = <% = count %>;
Function changelocation (locationid)
{
Document. Form. nsort_id.length = 0;
var locationid = locationid;
document. form. nsort_id.options [0] = New Option ('second-level category', '');
var I;
for (I = 0; I {< br> If (subcat [I] [1] = locationid)
{< br> document. form. nsort_id.options [document. form. nsort_id.length] = New Option (subcat [I] [0], subcat [I] [2]);
}< BR >}< br>
}< br>
<%
SQL = "select * From nnsort"
Rs. Open SQL, Conn, 1, 1
%>
<Script language = "JavaScript">
VaR onecount2;
Onecount2 = 0;
Subcat2 = new array ();
<%
Count2 = 0
Do while not Rs. EOF
%>
Subcat2 [<% = count2 %>] = new array ("<% = trim (RS (" nnsort_name ") %> ", "<% = trim (RS (" nsort_id ") %>", "<% = trim (RS (" nnsort_id ") %> ");
<%
Count2 = count2 + 1
Rs. movenext
Loop
Rs. Close
%>
Onecount2 = <% = count2 %>;
Function changelocation2 (locationid)
{
Document. Form. nnsort_id.length = 0;
VaR locationid = locationid;
VaR J;
Document. Form. nnsort_id.options [0] = New Option ('level 3 category ','');
For (j = 0; j <onecount2; j ++)
{
If (subcat2 [J] [1] = locationid)
{
Document. Form. nnsort_id.options [document. Form. nnsort_id.length] = New Option (subcat2 [J] [0], subcat2 [J] [2]);
}
}
}
</SCRIPT>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> JS three-level linkage drop-down box </title>
</Head>
<Body>
<Form name = "form" method = "Post" Action = "">
<Select name = "sort_id" onchange = "changelocation (document. form. sort_id.options [document. form. sort_id.selectedindex]. value); changelocation2 (document. form. nsort_id.options [document. form. nsort_id.selectedindex]. value); ">
<Option selected> Level 1 Classification </option>
<%
SQL = "select * From sort"
Rs. Open SQL, Conn, 1, 1
Do while not Rs. EOF
%>
<Option value = "<% = RS (" sort_id ") %>"> <% = RS ("sort_name") %> </option>
<%
Rs. movenext
Loop
Rs. Close
%>
</SELECT>
<Select name = "nsort_id" onchange = "changelocation2 (document. Form. nsort_id.options [document. Form. nsort_id.selectedindex]. Value);">
<Option selected> secondary classification </option>
</SELECT>
<Select name = "nnsort_id">
<Option selected> Level 3 Classification </option>
</SELECT>
</Form>
</Body>
</Html>
<%
Set rs = nothing
Conn. Close
Set conn = nothing
%>