如何用Strust1实现2级级联

RT,如何才能在struts1下实现2级级联?比如选择学生班级,就会出现对应的学生选项... RT,如何才能在struts1下实现2级级联?比如选择学生班级,就会出现对应的学生选项 展开
 我来答
匿名用户
2013-11-08
展开全部
Struts 加JScript 自己看看改动一下<html>
<head>
<title> Untitled Document </title>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
</head>
<body >
<div align= "center ">
<%
sql = "select * from xleibie order by xid "
set rs = conn.execute(sql)
%>
<script language = "JavaScript ">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[ <%=count%> ] = new Array( " <%= trim(rs( "xleibie ")%> ", " <%= trim(rs( "did ")%> ", " <%= trim(rs( "xid ")%> ";
<%
count = count + 1
rs.movenext
loop
rs.close
set rs=nothing
%>
onecount= <%=count%> ;

function changelocation(did)
{
document.myform.xleibie.length = 0;

var did=did;
var i;
document.myform.xleibie.options[0] = new Option( '==选择小类== ', ' ');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == did)
{
document.myform.xleibie.options[document.myform.xleibie.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

}
</script>
<%sql2 = "select * from pinpai order by pid "
set rs2 = conn.execute(sql2)
%>
<script language = "JavaScript ">
var onecount2;
onecount2=0;
subcat2 = new Array();
<%
count2 = 0
do while not rs2.eof
%>
subcat2[ <%=count2%> ] = new Array( " <%= trim(rs2( "pinpai ")%> ", " <%= trim(rs2( "xid ")%> ", " <%= trim(rs2( "pid ")%> ";
<%
count2 = count2 + 1
rs2.movenext
loop
rs2.close
set rs2=nothing
%>
onecount2= <%=count2%> ;

function changelocation2(pid)
{
document.myform.pinpai.length = 0;

var pid=pid;
var j;
document.myform.pinpai.options[0] = new Option( '==选择品牌== ', ' ');
for (j=0;j < onecount2; j++)
{
if (subcat2[j][1] == pid)
{
document.myform.pinpai.options[document.myform.pinpai.length] = new Option(subcat2[j][0], subcat2[j][2]);
}
}

}
</script>

<%
'------------------------------- 3 ------------------
sql3 = "select * from xinghao order by xhid "
set rs3 = conn.execute(sql3)
%>
<script language = "JavaScript ">
var onecount3;
onecount3=0;
subcat3 = new Array();
<%
count3 = 0
do while not rs3.eof
%>
subcat3[ <%=count3%> ] = new Array( " <%= trim(rs3( "xinghao ")%> ", " <%= trim(rs3( "pid ")%> ", " <%= trim(rs3( "xhid ")%> ";
<%
count3 = count3 + 1
rs3.movenext
loop
rs3.close
set rs3=nothing
%>
onecount3= <%=count3%> ;

function changelocation3(xhid)
{
document.myform.xinghao.length = 0;

var xhid=xhid;
var j;
document.myform.xinghao.options[0] = new Option( '==选择的型号== ', ' ');
for (j=0;j < onecount3; j++)
{
if (subcat3[j][1] == xhid)
{
document.myform.xinghao.options[document.myform.xinghao.length] = new Option(subcat3[j][0], subcat3[j][2]);
}
}

}
</script>
<form name= "myform " id= "myform " method= "post " action= "search '.asp " style= "margin:0 " target= "_blank ">
<select name= "dleibie " onChange= "changelocation(document.myform.dleibie.options[document.myform.dleibie.selectedIndex].value) " class=ty>
<option selected> --选择大类-- </option>
<%
sqldl= "select * from dleibie order by did "
set rsdl=conn.execute(sqldl)
do while not rsdl.eof
%>
<option value= " <%=rsdl( "did "%> "> <%=rsdl( "dleibie "%> </option>
<%
rsdl.movenext
loop
rsdl.close
%>
</select>

<select name= "xleibie " onChange= "changelocation2(document.myform.xleibie.options[document.myform.xleibie.selectedIndex].value) " class= "ty ">
<option selected> --选择小类-- </option>
</select>

<select name= "pinpai " onChange= "changelocation3(document.myform.pinpai.options[document.myform.pinpai.selectedIndex].value) " class= "ty ">
<option value= " " selected> --选择品牌-- </option>
</select>

<select name= "xinghao " id= "xinghao " class= "ty ">
<option selected> --选择型号-- </option>
</select>

<input type= "submit " name= "Submit " value= "搜索 " class= "ty ">
</form>
</div>
</body>
</html>
匿名用户
2013-11-08
展开全部
班级代码001000000 学生代码001000001 通过代码区分
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式