Data | database | dropdown ASP file:
<%@ Language=vbscript%>
<%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
Set conn = Server. CreateObject ("Adodb.connection")
Conn. Open "Test", "sa", ""
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[<%=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 (' = = = = = = ALL Regions = = = = '];
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>
<body>
<form name= "MyForm" method= "POST" >
<select name= "Biglocation" onchange= changelocation (document.myform.biglocation.options[ Document.myform.biglocation.selectedindex].value) ">
<%
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>
</form>
<script language= "JavaScript" >
Changelocation (Document.myform.biglocation.options[document.myform.biglocation.selectedindex].value);
</script>