Javascript interaction function, ASP + JavaScript example
Source: Internet
Author: User
<%
Connstr = "provider = Microsoft. Jet. oledb.4.0; Data Source =" + server. mappath ("data. mdb ")
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open connstr
%>
<Select name = "dlid" onchange = "changelocation (document. All. dlid. Options [document. All. dlid. selectedindex]. Value)">
<Option value = ""> select a Category </option>
<%
Strsql = "select * from temp where Reid = 0"
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open strsql, Conn, 1, 1
'Cyclic Display category
Do while not Rs. EOF
Response. Write "<option value =" & RS ("ID") & ">" & RS ("classname") & "</option>"
Rs. movenext
Loop
Rs. Close
Set rs = nothing
%>
</SELECT>
<Select name = "classtype" id = "select1"> <option value = ""> sub-class </option> </SELECT>
<%
'The following section intercepts small classes and generates JavaScript code
Strsql1 = "select * from temp where Reid <> 0"
Set RS1 = server. Createobject ("ADODB. recordset ")
Rs1.open strsql1, Conn, 1, 1
%>
<Script language = "JavaScript">
VaR onecount;
Onecount = 0;
Subcat = new array ();
<%
Count = 0
Do while not rs1.eof
%>
Subcat [<% = count %>] = new array ("<% = RS1 (" classname ") %>", "<% = RS1 (" Reid ") %> "," <% = RS1 ("ID") %> ");
<%
Count = count + 1
Rs1.movenext
Loop
Rs1.close
%>
Onecount = <% = count %>;
Function changelocation (locationid)
{
Document. All. classtype. Length = 0;
VaR locationid = locationid;
VaR I;
For (I = 0; I <onecount; I ++)
{
If (subcat [I] [1] = locationid)
{
Document. All. classtype. Options [document. All. classtype. Length] = New Option (subcat [I] [0], subcat [I] [2]);
}
}
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