四级ASP下拉列表的关联 10
现在有四个表:1、zhuanye:该表的字段有ID、zhuanye2、banji:该表的字段有ID、banji、zhuanye(其中zhuanye为长整型,对应上表的ID...
现在有四个表:
1、zhuanye:该表的字段有ID、zhuanye
2、banji:该表的字段有ID、banji、zhuanye(其中zhuanye为长整型,对应上表的ID)
3、xueqi:该表字段有ID、xueqi、banji(其中banji为长整型,对应上表的ID)
4、kemu:该表字段有ID、kemu、xueqi(其中xueqi为长整型,对应上表的ID)
现在需要做四个下拉列表:分别是专业、班级、学期、科目。
如果将专业改成计算机专业,则在班级列表中会显示出计算机专业的所有班级
如果将班级改成100班,则在学期列表中会显示出100班的六个学期
如果将学期改成某一个学期,则在科目列表中会显示该学期下的所有科目,如语文、数学等。
需要用ASP来做,拜托大侠帮忙。 展开
1、zhuanye:该表的字段有ID、zhuanye
2、banji:该表的字段有ID、banji、zhuanye(其中zhuanye为长整型,对应上表的ID)
3、xueqi:该表字段有ID、xueqi、banji(其中banji为长整型,对应上表的ID)
4、kemu:该表字段有ID、kemu、xueqi(其中xueqi为长整型,对应上表的ID)
现在需要做四个下拉列表:分别是专业、班级、学期、科目。
如果将专业改成计算机专业,则在班级列表中会显示出计算机专业的所有班级
如果将班级改成100班,则在学期列表中会显示出100班的六个学期
如果将学期改成某一个学期,则在科目列表中会显示该学期下的所有科目,如语文、数学等。
需要用ASP来做,拜托大侠帮忙。 展开
1个回答
展开全部
本页面为chaxun.asp
<%
'此处加连接数据库语句省略
set conn=......
conn.open "...... "
sql= "select zhuanye from zhuanye order by id "
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= "zy" id= "zy" onchange= "chaxun.asp?zy= '+this.value ">
<option value= " "> ==请选择专业== </option>
<%
if not rs.eof and not rs.bof then
do while not rs.eof%>
<option value= " <%=rs( "id ")%> " <%if trim(rs( "id "))=trim(request( "zy ")) then%> selected <%end if%> > <%=rs( "zhuanye ")%> </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?zy= <%=request( "zy")%> &bj= '+this.value ">
<option value= " "> ==请选择班级== </option>
<%if request( "zy") <> " " then
sql= "select * from banji where zhuanye= ' "&request( "zy ")& " ' "
set rs1=conn.execute(sql)
if not rs1.eof and not rs1.bof then
do while not rs1.eof%>
<option value= " <%=rs1( "id")%> " <%if trim(rs1( "id"))=trim(request( "bj ")) then%> selected <%end if%> > <%=rs( "banji")%> </option>
<%rs1.movenext
loop
end if
end if%>
</select> </td>
</tr>
<tr>
<td> <div align= "center ">学期 </div> </td>
<td> <select name= "xueqi" id= "xueqi" onchange= "chaxun.asp?zy= <%=request( "zy")%> &bj= <%=request( "bj ")%> &xq= '+this.value ">
<option value= " "> ==请选择学期== </option>
<%if request( "zy ") <> " " and reqeust( "bj ") <> " " then
sql= "select * from xueqi where banji= ' "&request( "bj ")& " ' "
set rs2=conn.execute(sql)
if not rs2.eof and not rs2.bof then
do while not rs2.eof%>
<option value= " <%=rs2( "id")%> " <%if trim(rs2( "id"))=trim(request( "xq")) then%> selected <%end if%> > <%=rs2( "xueqi")%> </option>
<%rs2.movenext
loop
end if
end if%>
</select> </td>
</tr>
<tr>
<td> <div align= "center ">科目</div> </td>
<td> <select name= "kemu" id= "kemu" onchange= "chaxun.asp?zy= <%=request( "zy")%> &bj= <%=request( "bj ")%> &xq= <%=request( "xq")%> &km= '+this.value ">
<option value= " "> ==请选择科目== </option>
<%if request( "zy ") <> " " and reqeust( "bj ") <> " " and reqeust( "xq") <> " " then
sql= "select * from kemu where xueqi= ' "&request( "xq")& " ' "
set rs3=conn.execute(sql)
if not rs3.eof and not rs3.bof then
do while not rs3.eof%>
<option value= " <%=rs3( "id")%> " <%if trim(rs3( "id"))=trim(request( "km")) then%> selected <%end if%> > <%=rs3( "kemu")%> </option>
<%rs3.movenext
loop
end if
end if%>
</select> </td>
</tr>
</table>
</form>
<%set conn=nothing%>
具体没有测试,可能会有点小问题,调试一下即可,你试试看,不行再问我
<%
'此处加连接数据库语句省略
set conn=......
conn.open "...... "
sql= "select zhuanye from zhuanye order by id "
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= "zy" id= "zy" onchange= "chaxun.asp?zy= '+this.value ">
<option value= " "> ==请选择专业== </option>
<%
if not rs.eof and not rs.bof then
do while not rs.eof%>
<option value= " <%=rs( "id ")%> " <%if trim(rs( "id "))=trim(request( "zy ")) then%> selected <%end if%> > <%=rs( "zhuanye ")%> </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?zy= <%=request( "zy")%> &bj= '+this.value ">
<option value= " "> ==请选择班级== </option>
<%if request( "zy") <> " " then
sql= "select * from banji where zhuanye= ' "&request( "zy ")& " ' "
set rs1=conn.execute(sql)
if not rs1.eof and not rs1.bof then
do while not rs1.eof%>
<option value= " <%=rs1( "id")%> " <%if trim(rs1( "id"))=trim(request( "bj ")) then%> selected <%end if%> > <%=rs( "banji")%> </option>
<%rs1.movenext
loop
end if
end if%>
</select> </td>
</tr>
<tr>
<td> <div align= "center ">学期 </div> </td>
<td> <select name= "xueqi" id= "xueqi" onchange= "chaxun.asp?zy= <%=request( "zy")%> &bj= <%=request( "bj ")%> &xq= '+this.value ">
<option value= " "> ==请选择学期== </option>
<%if request( "zy ") <> " " and reqeust( "bj ") <> " " then
sql= "select * from xueqi where banji= ' "&request( "bj ")& " ' "
set rs2=conn.execute(sql)
if not rs2.eof and not rs2.bof then
do while not rs2.eof%>
<option value= " <%=rs2( "id")%> " <%if trim(rs2( "id"))=trim(request( "xq")) then%> selected <%end if%> > <%=rs2( "xueqi")%> </option>
<%rs2.movenext
loop
end if
end if%>
</select> </td>
</tr>
<tr>
<td> <div align= "center ">科目</div> </td>
<td> <select name= "kemu" id= "kemu" onchange= "chaxun.asp?zy= <%=request( "zy")%> &bj= <%=request( "bj ")%> &xq= <%=request( "xq")%> &km= '+this.value ">
<option value= " "> ==请选择科目== </option>
<%if request( "zy ") <> " " and reqeust( "bj ") <> " " and reqeust( "xq") <> " " then
sql= "select * from kemu where xueqi= ' "&request( "xq")& " ' "
set rs3=conn.execute(sql)
if not rs3.eof and not rs3.bof then
do while not rs3.eof%>
<option value= " <%=rs3( "id")%> " <%if trim(rs3( "id"))=trim(request( "km")) then%> selected <%end if%> > <%=rs3( "kemu")%> </option>
<%rs3.movenext
loop
end if
end if%>
</select> </td>
</tr>
</table>
</form>
<%set conn=nothing%>
具体没有测试,可能会有点小问题,调试一下即可,你试试看,不行再问我
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询