下拉框传值
页面中有两个下拉框:一个是请示类型,一个是模板.请示类型下的值有会议纪要、人事任免、联合发文、会议通知。当我选择其中一个时,模板的下拉框中会出现相对应的值。当我选择会议纪...
页面中有两个下拉框:一个是请示类型,一个是模板.
请示类型下的值有会议纪要、人事任免、联合发文、会议通知。当我选择其中一个时,模板的下拉框中会出现相对应的值。当我选择会议纪要时会出现会议纪要的模板,当我选择人事任免时会出现人事任免的模板。
用你说的方法还是不行。。 展开
请示类型下的值有会议纪要、人事任免、联合发文、会议通知。当我选择其中一个时,模板的下拉框中会出现相对应的值。当我选择会议纪要时会出现会议纪要的模板,当我选择人事任免时会出现人事任免的模板。
用你说的方法还是不行。。 展开
展开全部
完成了.
以下是代码,一个JSP文件.
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script>
<!--
function bao(s)
{
var objSelect = document.myForm.sel2;
var StrName;
var strvalue;
for(var i=0;i<=(objSelect.length+1);i++)
{
objSelect.remove(objSelect.options[i]);
}
if(s=="1")
{
StrName="a";
strvalue="a";
var objOption = new Option(StrName,strvalue);
objSelect.options[objSelect.options.length] = objOption;
StrName="b";
strvalue="b";
objOption = new Option(StrName,strvalue);
objSelect.options[objSelect.options.length] = objOption;
StrName="c";
strvalue="c";
objOption = new Option(StrName,strvalue);
objSelect.options[objSelect.options.length] = objOption;
}
if(s=="2")
{
StrName="d";
strvalue="d";
var objOption = new Option(StrName,strvalue);
objSelect.options[objSelect.options.length] = objOption;
StrName="e";
strvalue="e";
objOption = new Option(StrName,strvalue);
objSelect.options[objSelect.options.length] = objOption;
StrName="f";
strvalue="f";
objOption = new Option(StrName,strvalue);
objSelect.options[objSelect.options.length] = objOption;
}
//txt.value+=s;
//选择后,让第一项被选中,这样,就有Change啦.
document.all.sel.options[0].selected=true;
}
-->
</script>
</head>
<body>
<h1>JSP Page</h1>
<form name="myForm">
<select name=sel onchange="bao(this.options[this.options.selectedIndex].value)">
<option value="">请选择</option>
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
</select>
<select name="sel2">
</select>
</form>
<!--<textarea id="txt"></textarea>-->
<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test="${param.sayHello}">
<!-- Let's welcome the user ${param.name} -->
Hello ${param.name}!
</c:if>
--%>
</body>
</html>
以下是代码,一个JSP文件.
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script>
<!--
function bao(s)
{
var objSelect = document.myForm.sel2;
var StrName;
var strvalue;
for(var i=0;i<=(objSelect.length+1);i++)
{
objSelect.remove(objSelect.options[i]);
}
if(s=="1")
{
StrName="a";
strvalue="a";
var objOption = new Option(StrName,strvalue);
objSelect.options[objSelect.options.length] = objOption;
StrName="b";
strvalue="b";
objOption = new Option(StrName,strvalue);
objSelect.options[objSelect.options.length] = objOption;
StrName="c";
strvalue="c";
objOption = new Option(StrName,strvalue);
objSelect.options[objSelect.options.length] = objOption;
}
if(s=="2")
{
StrName="d";
strvalue="d";
var objOption = new Option(StrName,strvalue);
objSelect.options[objSelect.options.length] = objOption;
StrName="e";
strvalue="e";
objOption = new Option(StrName,strvalue);
objSelect.options[objSelect.options.length] = objOption;
StrName="f";
strvalue="f";
objOption = new Option(StrName,strvalue);
objSelect.options[objSelect.options.length] = objOption;
}
//txt.value+=s;
//选择后,让第一项被选中,这样,就有Change啦.
document.all.sel.options[0].selected=true;
}
-->
</script>
</head>
<body>
<h1>JSP Page</h1>
<form name="myForm">
<select name=sel onchange="bao(this.options[this.options.selectedIndex].value)">
<option value="">请选择</option>
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
</select>
<select name="sel2">
</select>
</form>
<!--<textarea id="txt"></textarea>-->
<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test="${param.sayHello}">
<!-- Let's welcome the user ${param.name} -->
Hello ${param.name}!
</c:if>
--%>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<select name="请示类型" onchange="whileChange(this)">
<option value="会议纪要">会议纪要</option>
<option value="人事任免">人事任免</option>
...............
</select>
<select name="模板">
<option value="会议纪要">会议纪要</option>
<option value="人事任免">人事任免</option>
...............
</select>
<script language='javascript'>
function whileChange(obj){
模板.value = obj.value;
}
</script>
<option value="会议纪要">会议纪要</option>
<option value="人事任免">人事任免</option>
...............
</select>
<select name="模板">
<option value="会议纪要">会议纪要</option>
<option value="人事任免">人事任免</option>
...............
</select>
<script language='javascript'>
function whileChange(obj){
模板.value = obj.value;
}
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询