jsp如何获取select列表里的值
a.jsp页面嵌入blank.jsp页面,如何在a.jsp获取select的值,并赋给变量?<td><%@includefile="blank.jsp"%></td>bl...
a.jsp页面嵌入blank.jsp页面,如何在a.jsp获取select的值,并赋给变量?
<td>
<%@ include file="blank.jsp"%>
</td>
blank.jsp页面有代码:
<form name="frm">
<select name="s1" onChange="redirec(document.frm.s1.options.selectedIndex)">
<option selected>选择部门</option>
<option value="1">信息部</option>
<option value="2">人事部</option>
<option value="3">物业部</option>
</select>
<select name="s2">
<option value="请选择" selected>请选择</option>
</select>
<jsp:useBean id="present" class="xxb.date.DateBean" scope="page"/>
<input name="date" class="editbox4" value="<%=present.today("yyyy-MM-dd")%>" size="20">
</form>
<script language="javascript">
//获取一级菜单长度
var select1_len = document.frm.s1.options.length;
var select2 = new Array(select1_len);
//把一级菜单都设为数组
for (i=0; i<select1_len; i++)
{
select2[i] = new Array();
}
//定义基本选项
select2[0][0] = new Option("请选择", " ");
select2[1][0] = new Option("aa", " ");
select2[1][1] = new Option("bb", " ");
select2[1][2] = new Option("cc", " ");
select2[2][0] = new Option("张", " ");
select2[2][1] = new Option("王", " ");
select2[2][2] = new Option("李", " ");
select2[3][0] = new Option("赵", " ");
select2[3][1] = new Option("刘", " ");
select2[3][2] = new Option("马", " ");
//联动函数
function redirec(x)
{
var temp = document.frm.s2;
for (i=0;i<select2[x].length;i++)
{
temp.options[i]=new Option(select2[x][i].text,select2[x][i].value);
}
temp.options[0].selected=true;
}
</script> 展开
<td>
<%@ include file="blank.jsp"%>
</td>
blank.jsp页面有代码:
<form name="frm">
<select name="s1" onChange="redirec(document.frm.s1.options.selectedIndex)">
<option selected>选择部门</option>
<option value="1">信息部</option>
<option value="2">人事部</option>
<option value="3">物业部</option>
</select>
<select name="s2">
<option value="请选择" selected>请选择</option>
</select>
<jsp:useBean id="present" class="xxb.date.DateBean" scope="page"/>
<input name="date" class="editbox4" value="<%=present.today("yyyy-MM-dd")%>" size="20">
</form>
<script language="javascript">
//获取一级菜单长度
var select1_len = document.frm.s1.options.length;
var select2 = new Array(select1_len);
//把一级菜单都设为数组
for (i=0; i<select1_len; i++)
{
select2[i] = new Array();
}
//定义基本选项
select2[0][0] = new Option("请选择", " ");
select2[1][0] = new Option("aa", " ");
select2[1][1] = new Option("bb", " ");
select2[1][2] = new Option("cc", " ");
select2[2][0] = new Option("张", " ");
select2[2][1] = new Option("王", " ");
select2[2][2] = new Option("李", " ");
select2[3][0] = new Option("赵", " ");
select2[3][1] = new Option("刘", " ");
select2[3][2] = new Option("马", " ");
//联动函数
function redirec(x)
{
var temp = document.frm.s2;
for (i=0;i<select2[x].length;i++)
{
temp.options[i]=new Option(select2[x][i].text,select2[x][i].value);
}
temp.options[0].selected=true;
}
</script> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询