关于二级联动下拉列表的问题,请大家帮帮忙
数据表:depart表(dept_id,dept_name)
staff表(staff_no,staff_name,dept_id)
表中都有数据
代码如下:
<!--#include file="conn.asp"-->
<%
set rs=server.createobject("adodb.recordset")
rs.open "select * from staff",conn,1,1
%>
<script language="JavaScript">
var onecount;
onecount=0;
subcat=new Array();
<%
count=0
do while not rs.eof
%>
subcat[<%=count%>]=new Array("<%=rs("staff_name")%>","<%=rs("depart_id")%>","<%=rs("staff_no")%>");
<%
count=count+1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>
function changestaff(values)
{
document.form3.staff.length=0;
var values=values;
var i;
for (i=0;i<onecount;i++)
{
if (subcat[i][1]==values)
{
document.form3.staff.options[document.form3.staff.length]=new Option(subcat[i][0],subcat[i][2]);
}
}
}
</script>
<form action="kaoqin_query_staff.asp" method="post" name="form3">
<label>请选择部门:</label>
<select name="deptment" size="1" >
<option >未选定部门</option>
<%
set rs0=server.CreateObject("ADODB.recordset")
sql0="select * from depart"
rs0.open sql0,conn,3,1
while not rs0.eof
response.Write("<option value="&rs0("dept_id")&">"&rs0("dept_name")&"</option>")
rs0.MoveNext
wend
%>
</select>
<label>请选择员工:</label>
<select name="staff" size="1">
<option name="">未选定部门</option>
</select>
<input type="submit" name="submit3" value="查询">
</form>
结果在staff中一个选项没有
[[italic] 本帖最后由 seven_eve 于 2007-12-5 10:13 编辑 [/italic]]