ASP news topic switch + JS

Source: Internet
Author: User

<%
Dim rs
Dim SQL
Dim count
Set rs = server. Createobject ("ADODB. recordset ")
SQL = "select * From kml_sclass"
Rs. Open SQL, Conn, 1, 1
%>
<Script language = "JavaScript">
VaR onecount;
Onecount = 0;
Subcat = new array ();
<%
Count = 0
Do while not Rs. EOF
%>
Subcat [<% = count %>] = new array ("<% = trim (RS (" sclassname ") %> ", "<% = trim (RS (" bclassid ") %>", "<% = trim (RS (" sclassid ") %> ");
<%
Count = count + 1
Rs. movenext
Loop
Rs. Close
%>
Onecount = <% = count %>;

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

VaR locationid = locationid;
VaR I;
For (I = 0; I <onecount; I ++)
{
If (subcat [I] [1] = locationid)
{
Document. myform. sclassid. Options [document. myform. sclassid. Length] = New Option (subcat [I] [0], subcat [I] [2]);
}
}

}
</SCRIPT>
</Head>
<Body>
<Br>
<Form name = "myform" method = "Post" Action = "? Action = addsave ">
<Table width = "80%" border = "0" align = "center" cellpadding = "2" cellspacing = "1" bgcolor = "# cccccc">
<Tr bgcolor = "# f6f6f6">
<TD Height = "25" colspan = "2"> <Div align = "center"> <strong> modify news </strong> </div> </TD>
</Tr> <tr bgcolor = "# f6f6f6"> <TD align = "center" Height = "25"> News style: </TD> <input name = "jibie" type = "radio" value = "0" Checked>
Chinese version </TD> </tr>
<Tr>
<TD width = "15%" Height = "25" align = "right" bgcolor = "# f6f6f6"> Article type: </TD>
& Lt; TD width = "85%" bgcolor = "# ffffff" & gt;
<%
SQL = "select * From kml_bclass"
Rs. Open SQL, Conn, 1, 1
If Rs. EOF and Rs. bof then
Response. Write "add a column first. "
Response. End
Else
%>
<Select name = "bclassid" onchange = "changelocation (document. myform. bclassid. Options [document. myform. bclassid. selectedindex]. Value)" size = "1">
<Option selected value = "<% = trim (RS (" bclassid ") %>"> <% = trim (RS ("bclassname") %> </option>
<% Dim selclass
Selclass = RS ("bclassid ")
Rs. movenext
Do while not Rs. EOF
%>
<Option value = "<% = trim (RS (" bclassid ") %>"> <% = trim (RS ("bclassname") %> </option>
<%
Rs. movenext
Loop
End if
Rs. Close
%>
</SELECT>
<Select name = "sclassid">
<%
SQL = "select * From kml_sclass where bclassid =" & selclass
Rs. Open SQL, Conn, 1, 1
If not (Rs. EOF and Rs. bof) then
%>
<Option selected value = "<% = RS (" sclassid ") %>"> <% = RS ("sclassname") %> </option>
<%
Rs. movenext
Do while not Rs. EOF
%>
<Option <% if rsedit ("sclassid") = RS ("sclassid") Then %> selected <% end if %> value = "<% = RS (" sclassid ") %> "> <% = RS (" sclassname ") %> </option>
<%
Rs. movenext
Loop
End if
Rs. Close
Set rs = nothing
%>
</SELECT>

Related Article

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.