Three-level dropdown box linked to the database version

Source: Internet
Author: User
' Three-level drop down box for continuous motion
'
Database
' Location
' Table 1 loaction on the surface
' Field
' Loactionid
' Loactionname name
' Table 2 District Area table
' Field
' LocationID
' Districtid
' Districtname
' Table 3 County table of village
' Field
' Districtid
' Villageid
' Villagename

<%option explicit%>


<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=;d atabase=location;"


sql = "SELECT * from District ORDER by LocationID ASC"
Set rs = conn.execute (SQL)
%>
<script language = "JavaScript" >
var Onecount;
onecount=0;
subcat = new Array ();
<%
Count = 0
Do as not rs.eof
%>
SUBCAT[&LT;%=COUNT%&GT] = 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 (' = = the region of the selected city = = ', ');
For (I=0;i < onecount; i++)
{
if (subcat[i][1] = = LocationID)
{
Document.myform.smalllocation.options[document.myform.smalllocation.length] = new Option (subcat[i][0], subcat[i][2 ]);
}
}

}
</script>


&LT;%SQL2 = "Select * from Village ORDER by Districtid ASC"
Set rs2 = Conn.execute (SQL2)
%>
<script language = "JavaScript" >
var Onecount2;
onecount2=0;
SUBCAT2 = new Array ();
<%
Count2 = 0
Do as not rs2.eof
%>
SUBCAT2[&LT;%=COUNT2%&GT] = new Array ("<%= Trim (rs2 (" villagename))%> "," <%= Trim (rs2 ("Districtid"))%> " , "<%= Trim (rs2 (" Villageid "))%>");
<%
Count2 = Count2 + 1
Rs2.movenext
Loop
Rs2.close
Set rs2=nothing
%>
onecount2=<%=count2%>;

function Changelocation2 (Villageid)
{
document.myform.village.length = 0;

var Villageid=villageid;
var J;
Document.myform.village.options[0] = new Option (' = = County District = = ', ' of the selected region = ');
For (J=0;j < Onecount2; j + +)
{
if (subcat2[j][1] = = Villageid)
{
Document.myform.village.options[document.myform.village.length] = new Option (subcat2[j][0], subcat2[j][2]);
}
}

}
</script>




<body>
<form name= "MyForm" method= "POST" >
Title: <input type= "text" name= "T2" size= ">"

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

Category: <select name= "Biglocation" size= "1" >
<option selected> Please select your province </option>
<%

SQL1 = "SELECT * from Location ORDER by locationname ASC"
Set rs1 = conn. Execute (SQL1)
Do as 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" >
<option selected Value= "" >== All areas ==</option>
</select><select name= "Village" size= "1" >
<option selected>== All County District ==</option>
</select>


Key words: <input type= "text" name= "T4" size= ">"

Content: <textarea rows= "9" name= "S1" cols= "Wuyi" ></textarea>
</form>

</body>



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.