改写了一下,实现一对多的关系:
<form name=f1 METHOD="POST">
<%
db="select.mdb"
Set objconn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
objConn.Open connstr
Set RSClass = objConn.Execute("SELECT * FROM class Order by fldClass")
If RSClass.EOF Then
Response.Write "没有记录。<BR>"
Else
%>
<SELECT NAME="class" style="FONT-SIZE: 9pt" SIZE=1 ONCHANGE="classselected(this);" >
<%
sjavascript = "function classselected(elem){" &_
vbCrlf & _
"for (var i = document.f1.sort.options.length; i >= 0; i--){" & vbCrlf & _
"document.f1.sort.options[i] = null;" & _
vbCrlf
Do Until RSClass.EOF
If sLastClass <> RSClass("fldClass") Then
sLastClass = RSClass("fldClass")
Response.Write "<OPTION value=" & RSClass("fldID") & ">" & sLastClass & "</OPTION>"
sjavascript = sjavascript & "}" & vbCrlf & _
"if (elem.options[elem.selectedIndex].value==" & _
RSClass("fldID") & "){" & vbCrlf
End If
ssjavascript=Vbcrlf
city=split(RSClass("fldSort"),"|")
for i=0 to ubound(city)
ssjavascript = ssjavascript & _
"document.f1.sort.options[" & _
i&"] = new Option("" & _
city(i) & "","" & RSClass("fldID") & "");" & _
vbCrlf
next
sjavascript=sjavascript&_
ssjavascript
RSClass.MoveNext
Loop
Response.Write "</SELECT>"
Response.Write "<SELECT NAME=""sort"" style=""FONT-SIZE: 9pt"" SIZE=1>"
Response.Write "<OPTION>[请选择]</OPTION>"
Response.Write "</SELECT>"
sjavascript = sjavascript & vbCrlf & "}" & vbCrlf & "}" & vbCrlf
Response.Write "<SCR" & "IPT LANGUAGE=""javascript"">" & vbCrlf
Response.Write sjavascript & vbCrlf & "</SCR" & "IPT>" & vbCrlf
End If
RSClass.Close
Set RSClass = Nothing%>
</form>
|