我的意思是从第一个下拉框选择完班次后,从数据库中查找,在第二个下拉框中将所有所选班次的人员全部列出!
<%set rs=server.createobject("adodb.recordset")
sql = "select * from worker"
rs.open sql,conn,1,1%>
<script language="javascript">
var second = new Array();
<%
i=0
do while not rs.eof
studentid=1+i
arrid=i
response.write("second["&arrid&"] = new Array('"&rs("bc")&"','studuent"&studentid&"','"&rs("name")&"');" & vbcrlf)
rs.movenext
i=i+1
loop
rs.close
%>
function changeFirstType(field,subfield,classid){
subfield.length = 0;
var classid=classid;
var i;
for (i=0;i < second.length; i++)
{
if (second[i][0] == classid)
{
subfield.options[subfield.length] = new Option(second[i][2], second[i][1]);
}
}
}
</script>
这部分代码改为
<%set rs=server.createobject("adodb.recordset")
sql = "select * from worker"
rs.open sql,conn,1,1%>
<script language="javascript">
var second = new Array();
<%
i=0
do while not rs.eof
studentid=1+i
arrid=i
response.write("second["&arrid&"] = new Array('"&rs("bc")&"','studuent"&studentid&"','"&rs("name")&"');" & vbcrlf)
rs.movenext
i=i+1
loop
rs.close
%>
function changeFirstType(classid){
var classid=classid;
var i;
var clsStr;
clsStr="";
for (i=0;i < second.length; i++)
{
if (second[i][0] == classid)
{
clsStr+=second[i][2]+" "+second[i][1]+"|";
}
}
var TempClsAry;
TempClsAry=clsStr.split("|");
document.form.smallclassid.options.length=TempClsAry.length;
for(var j=0;j<TempClsAry.length;j++)
{
document.form.smallclassid.options[j].value=TempClsAry[j];
document.form.smallclassid.options[j].text=TempClsAry[j];
}
document.form.smallclassid.options.length-=1;
}
</script>
另外一部分代码
<form name=form method="post">
<SELECT id=bigclassid onchange=changeFirstType(this,this.form.smallclassid,this.options[this.selectedIndex].value); name=bigclassid>
<OPTION value="甲班" selected>甲班</OPTION>
<OPTION value="乙班">乙班</OPTION>
<OPTION value="丙班">丙班</OPTION>
<OPTION value="丁班">丁班</OPTION>
<OPTION value="白班">白班</OPTION>
</SELECT>
<SELECT id=smallclassid name=smallclassid>
<option></option>
</SELECT>
</form>
改为
<form name=form method="post">
<SELECT id=bigclassid onchange=changeFirstType(this.options[this.selectedIndex].value); name=bigclassid>
<OPTION value="甲班" selected>甲班</OPTION>
<OPTION value="乙班">乙班</OPTION>
<OPTION value="丙班">丙班</OPTION>
<OPTION value="丁班">丁班</OPTION>
<OPTION value="白班">白班</OPTION>
</SELECT>
<SELECT id=smallclassid name=smallclassid>
<option></option>
</SELECT>
</form>
问一下,为什么我改完了运行后显示不出来,而且还有错!
行: 153
字符: 49
错误: 未结束的字符串常量
代码: 0
URL: http://10.9.3.55/jwgl/bb.asp
行: 308
字符: 1
错误: 缺少对象
代码: 0
URL: http://10.9.3.55/jwgl/bb.asp
行: 308
字符: 1
错误: 缺少对象
代码: 0