<%
Response. write "<select name =" "class_id" "onChange =" "classselect (this);" ">" & vbCrlf
StrJS = "function classselect (obj) {for (var I = document. refer. class_c_id.options.length; I> = 0; I --) {document. refer. class_c_id.options [I] = null; "& vbCrlf 'clears the JS code of the original option object
SQL = "select class_id, class_name from class order by class_order"
Set rsw.conn.exe cute (SQL)
While not rs. eof
Response. write "<option value =" & rs ("class_id ")
If class_id <> "then
If rs ("class_id") = CInt (class_id) then' enables the option of the corresponding parent class to be selected. The CInt function must be added; otherwise, the function will not work.
Response. write "selected"
End if
End if
Response. write ">" & rs ("class_name") & "</option>" & vbCrlf
StrJS = strJS & "}" & vbCrlf & "if (obj. options [obj. selectedIndex]. value =" & rs ("class_id") & ") {" & vbCrlf
Sql1 = "select class_c_id, class_c_name from class_c where class_id =" & rs ("class_id") & "order by class_c_order"
Set rs1=conn.exe cute (sql1)
While not rs1.eof
StrJS = strJS & "document. refer. class_c_id.options [document. refer. class_c_id.options.length] = new Option ('"& rs1 (" class_c_name ") &"', '"& rs1 (" class_c_id ") &"'); "& vbCrlf
Rs1.movenext
Wend
Rs. movenext
Wend
'To make the option of the first subclass not null ============================== ======================================
If class_id = "" then
SQL = "select class_id, class_name from class"
Set rsw.conn.exe cute (SQL)
SQL = "select class_c_id, class_c_name from class_c where class_id =" & rs ("class_id") & "order by class_c_order"
Else
SQL = "select class_c_id, class_c_name from class_c where class_id =" & class_id & "order by class_c_order"
End if
Set rsw.conn.exe cute (SQL)
While not rs. eof
If class_c_id <> "then
If rs ("class_c_id") = CInt (class_c_id) then' makes the option of the corresponding subclass selected. If placed before string connection
StrJS3 = "var option_length = document. refer. class_c_id.options.length;" & vbCrlf
StrJS2 = "document. refer. class_c_id.options [option_length]. selected = true;" & vbCrlf
Else
StrJS3 = ""
End if
End if
StrJS1 = strJS1 & strJS3 & "document. refer. class_c_id.options [document. refer. class_c_id.options.length] = new Option ('"& rs (" class_c_name ") &"', '"& rs (" class_c_id ") &"'); "& vbCrlf
Rs. movenext
Wend
'================================================ ========================================================== ===
StrJS = strJS & "}" & vbCrlf & "}" & vbCrlf
Response. write "</select>"
Response. write "<select name =" "class_c_id" ">"
Response. write "</select>"
Response. write "<script language =" "JavaScript" ">" & vbCrlf 'output JS scripts
Response. write strJS1 & vbCrlf & strJS2 & vbCrlf
Response. write strJS & "</SCRIPT>" & vbCrlf
Conn. close
Set conn = nothing
%>