两级关联的实现
参数主要包括,到数据库的连接,当前返回的上一级,当前级
<%function getclasslist(conn,subjectid,nowselect)
if not nowselect="" then
if not isnumeric(nowselect) then
call nerror(-4)
else selindex=cint(nowselect)
end if
end if
result="<option>--==先选择专业==--</option>"
if not subjectid="" then
if not isnumeric(subjectid) then
call nerror(-4)
end if
sql="select * from CLASS where DUSER is null and SID="&subjectid
call crecset(sql,conn,rs4,0,1)
if rs4.eof then
result="<option>没有创建班级</option>"
else
result=""
do while not rs4.eof
str=""
if selindex=rs4("ID") then
str="selected"
end if
result=result&"<option value='"&rs4("ID")&"' "&str&">"&rs4("CNAME")&"</option>"
rs4.movenext
loop
call srecset(rs4)
end if
end if
getclasslist=result
end function
function gettermlist(conn,cid)
result="<option>无</option>"
if not cid="" then
if not isnumeric(cid) then
call nerror(-4)
end if
sql="select * from CLASS where DUSER is null and ID="&cid
call crecset(sql,conn,rs4,0,1)
if rs4.eof then
result="<option>ERROR</option>"
else
result=""
for temnum=1 to 8
if not rs4("term"&cstr(temnum)) then
result=result&"<option value='"&temnum&"'>"&temnum&"</option>"
end if
next
call srecset(rs4)
end if
end if
gettermlist=result
end function
%>
<select name="select" class="sel" onChange="javascript:window.location.href='thepage.asp?sid='+
this.options[this.selectedIndex].value">
<%if request.Form("sid")="" then%>
<option value="" selected>请先选择专业</option>
<%end if%>
<%=subjectlist(conn2,request.Form("sid"))%>
</select>
<br>
班级:
<select name="classid" class="sel" >
<%if request.Form("sid")="" then%>
<option value="" selected>请先选择专业</option>
<%end if%>
<%=getclasslist(conn2,request.Form("sid"),"")%>
</select>