数据库的相关表的在下面,这个问题我感觉是有点繁,不行就算了,
我的问题,主要是一个二级连动的问题,常见的二级连动网上有教程,所以不会js也会了,但是我这个情况有点特殊,第一个下拉框是teacher第二个是班级,class
但是class里是通过"|"来分的,又我不会js所以不会变通,请指点,
代码如下
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!--#include file="lockip.asp"-->
<script language = "JavaScript">
var onecount;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("class_e"))%>","<%= trim(rs("teacher"))%>","<%= trim(rs("teacher"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.reg.class_e.length = 1;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.reg.class_e.options[document.reg.class_e.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
<% call opendb()
set rs=server.createobject("adodb.recordset")
sql = "select * from eric_manager where purview='2'"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "当前还没有教师注册"
else
%>
<select name="teacher" onChange="changelocation(document.reg.teacher.options[document.reg.teacher.selectedIndex].value)" size="1">
<option selected value="<%=trim(rs("teacher"))%>"><%=trim(rs("teacher"))%></option>
<%
dim selclass
selclass=rs("teacher")
rs.movenext
do while not rs.eof
%>
<option value="<%=trim(rs("teacher"))%>"><%=trim(rs("teacher"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<select name="class_e">
<option value="" selected>--选择班级--</option>
<%
sql="select * from eric_manager where teacher='" & selclass & "' and class_e<>''"
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
dim class_e
class_e=rs("class_e")
if instr(class_e,"|")>0 then
array_class_e=split(class_e,"|")
for i=0 to ubound(array_class_e)
response.write "<option selected>" & array_class_e(i) & "</option>"
next
else
response.write "<option selected>" & class_e & "</option>"
end if
call closers()
call closedb()
end if%>
</select>