Three-Level linkage drop-down box (database version)-vomit blood recommendation

Source: Internet
Author: User
Three-Level linkage drop-down box (database version) -- vomiting blood recommendation
Three-Level drop-down box Linkage
'
'Database:
'Location
'Table 1 loaction location table
'Field
'Loactionid
'Loactionname
'Table 2 region where district is located
'Field
'Locationid
'Districtid
'Districtname
'Table 3 the county/district table of the village
'Field
'Districtid
'Languageid
'Languagename

<% Option explicit %>
<HTML>
<Head>
<Title> List </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<%
Dim Conn
Dim rs
Dim SQL
Dim count
Dim RS1
Dim sql1
Dim rs2
Dim sql2
Dim count2

Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "provider = sqloledb; Data Source = 192.168.0.33; uid = sa; Pwd =; database = location ;"

SQL = "select * From District order by locationid ASC"
Set rs = conn.exe cute (SQL)
%>
<Script language = "JavaScript">
VaR onecount;
Onecount = 0;
Subcat = new array ();
<%
Count = 0
Do while not Rs. EOF
%>
Subcat <% = count %> = new array ("<% = trim (RS (" districtname ") %> ", "<% = trim (RS (" locationid ") %>", "<% = trim (RS (" districtid ") %> ");
<%
Count = count + 1
Rs. movenext
Loop
Rs. Close
Set rs = nothing
%>
Onecount = <% = count %>;

Function changelocation (locationid)
{
Document. myform. smalllocation. Length = 0;

VaR locationid = locationid;
VaR I;
Document. myform. smalllocation. Options <0> = New Option ('= region of the selected city = ','');
For (I = 0; I <onecount; I ++)
{
If (subcat <1 >== locationid)
{
Document. myform. smalllocation. Options = New Option (subcat <0>, subcat <2> );
}
}

}
</SCRIPT>

<% Sql2 = "select * from village order by districtid ASC"
Set rs2 = conn.exe cute (sql2)
%>
<Script language = "JavaScript">
VaR onecount2;
Onecount2 = 0;
Subcat2 = new array ();
<%
Count2 = 0
Do while not rs2.eof
%>
Subcat2 <% = count2 %> = new array ("<% = trim (rs2 (" languagename ") %> ", "<% = trim (rs2 (" districtid ") %>", "<% = trim (rs2 (" languageid ") %> ");
<%
Count2 = count2 + 1
Rs2.movenext
Loop
Rs2.close
Set rs2 = nothing
%>
Onecount2 = <% = count2 %>;

Function changelocation2 (languageid)
{
Document. myform. Village. Length = 0;

VaR languageid = languageid;
VaR J;
Document. myform. Village. Options <0> = New Option ('= the county/district of the selected region = ','');
For (j = 0; j <onecount2; j ++)
{
If (subcat2 <1 >== languageid)
{
Document. myform. Village. Options = New Option (subcat2 <0>, subcat2 <2> );
}
}

}
</SCRIPT>

</Head>
<Body>
<Form name = "myform" method = "Post">
Question: <input type = "text" name = "T2" size = "20">

Source: <input type = "text" name = "T3" size = "20">

Category: <select name = "biglocation" onchange = "changelocation (document. myform. biglocation. Options. Value)" size = "1">
<Option selected> select your province </option>
<%

Sql1 = "select * from location order by locationname ASC"
Set RS1 = conn. Execute (sql1)
Do while not rs1.eof
%>
<Option value = "<% = trim (RS1 (" locationid ") %>"> <% = trim (RS1 ("locationname") %> </option>

<%
Rs1.movenext
Loop
Rs1.close
Set RS1 = nothing
Conn. Close
Set conn = nothing
%>
</SELECT> <select name = "smalllocation" onchange = "changelocation2 (document. myform. smalllocation. Options. Value)">
<Option selected value = "" >== all regions ==</option>
</SELECT> <select name = "Village" size = "1">
<Option selected >== all counties ==</option>
</SELECT>

Keywords: <input type = "text" name = "T4" size = "20">

Content: <textarea rows = "9" name = "S1" Cols = "51"> </textarea>
</Form>

</Body>
</Html>

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.