id 學校 班級 姓名
1 中學 壹班 王壹
2 中學 三班 孫二
3 高中 二班 張三
妳現在第壹級選擇是學校,第二級是班級
本頁面為chaxun.asp
<%
'此處加連接數據庫語句省略
set conn=......
conn.open "...... "
sql= "select distinct 學校 from 人員表 "
set rs=conn.execute(sql)%>
<form id= "form1 " name= "form1 " method= "post " action= "chaxun.asp ">
<table width= "600 " border= "1 ">
<tr>
<td width= "179 "> <div align= "center "> 學校 </div> </td>
<td width= "405 ">
<select name= "xuexiao " id= "xuexiao " onchange= "chaxun.asp?xx= '+this.value ">
<option value= " "> ==請選擇學校== </option>
<%
if not rs.eof and not rs.bof then
do while not rs.eof%>
<option value= " <%=rs( "學校 ")%> " <%if trim(rs( "學校 "))=trim(request( "xx ")) then%> selected <%end if%> > <%=rs( "學校 ")%> </option>
<%rs.movenext
loop
end if%>
</select>
</td>
</tr>
<tr>
<td> <div align= "center "> 班級 </div> </td>
<td> <select name= "banji " id= "banji " onchange= "chaxun.asp?xx= <%=request( "xx ")%> &bj= '+this.value ">
<option value= " "> ==請選擇班級== </option>
<%if request( "xx ") <> " " then
sql= "select distinct 班級 from 人員表 where 學校= ' "&request( "xx ")& " ' "
set rs1=conn.execute(sql)
if not rs1.eof and not rs1.bof then
do while not rs1.eof%>
<option value= " <%=rs1( "班級 ")%> " <%if trim(rs1( "班級 "))=trim(request( "bj ")) then%> selected <%end if%> > <%=rs( "班級 ")%> </option>
<%rs1.movenext
loop
end if
end if%>
</select> </td>
</tr>
<tr>
<td> <div align= "center "> 姓名 </div> </td>
<td> <select name= "name " id= "name " onchange= "chaxun.asp?xx= <%=request( "xx ")%> &bj= <%=request( "bj ")%> &name= '+this.value ">
<option value= " "> ==請選擇人員== </option>
<%if request( "xx ") <> " " and reqeust( "bj ") <> " " then
sql= "select 姓名 from 人員表 where 學校= ' "&request( "xx ")& " ' and 班級= ' "&request( "bj ")& " ' "
set rs2=conn.execute(sql)
if not rs2.eof and not rs2.bof then
do while not rs2.eof%>
<option value= " <%=rs2( "姓名 ")%> " <%if trim(rs2( "姓名 "))=trim(request( "name ")) then%> selected <%end if%> > <%=rs2( "姓名 ")%> </option>
<%rs2.movenext
loop
end if
end if%>
</select> </td>
</tr>
</table>
</form>
<%set conn=nothing%>
具體沒有測試,妳試試看,不行再問我