在JSP中对select和textarea读取、赋值的实例

<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<SCRIPT type=text/javascript>

function clearContent(obj){
obj.value = "";
}
function addname(obj1,obj2)
{
var oSelected = document.getElementById(obj2);
var selectedValue = oSelected.options[oSelected.selectedIndex].value;
window.alert(selectedValue);
var oarea=document.getElementById(obj1).value;
window.alert("1");
window.alert(oarea);

document.getElementById(obj1).value=selectedValue+","+oarea;

}

</SCRIPT>
<SCRIPT>
var menu_id=0;

function setPointer(theRow, thePointerColor,menu_id_over)
{
if(menu_id!=menu_id_over)
theRow.bgColor = thePointerColor;
}

function view_menu1()

window.location="car-managelist.jsp";
menu_id=1;
menu_1.bgColor='#D9E8FF';
menu_2.bgColor='#DDDDDD';
}

function view_menu2()
{
window.location="car-applylist.jsp";
menu_id=2;
menu_1.bgColor='#DDDDDD';
menu_2.bgColor='#D9E8FF';
}

</SCRIPT>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'car-manager.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0"> 
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

<style type="text/css">
<!--
.STYLE1 {color: #0000FF}
body {
background-color: #eff6fe;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>

<body>
<table width="200" border="0">
<tr>
<td height="36"> <input name="carq1" type="button" id="carq1" onClick="view_menu1()" onMouseOver="setPointer(this, '#B3D1FF',1)" value="车辆管理列表" > 
<a href="car/car-applylist.jsp"></a></td>
<td> <input name="carq2" type="button" id="carq2" value="用车申请列表" onClick="view_menu2()" onMouseOver="setPointer(this, '#B3D1FF',2)" > </td>
</tr>
</table>
<p class="big3 STYLE1"><strong>指定调度人</strong></p>
<table width="696" height="120" border="1" align="center" cellspacing="0" bordercolor="#666666">
<tr>
<td width="99" height="80" bgcolor="#c2efcb">车辆调度人员:</td>
<td width="581"><form name="form1" method="post" action="">
<textarea name="car1" cols="55" rows="5"></textarea>
<select name="car3" id="car3">
<option selected value="梨花">梨花</option>
<option value="梅花">梅花</option>
<option value="荷花">荷花</option>
<option value="桃花">桃花</option>
</select>
<a href="javascript:;" onClick="addname('car1','car3')">添加</a>&nbsp; &nbsp;&nbsp;<a href="javascript:;" onClick="clearContent(car1)">清空</a>
</form>
</td>
</tr>
<tr>
<td height="30" colspan="2" bgcolor="#eff7ff"><form name="form2" method="post" action="">
<div align="center">
<input name="car2" type="button" id="car2" onClick="location='car-ok.jsp'" value="保存">
&nbsp;&nbsp;&nbsp;</div>
</form>
</td>
</tr>
</table>
<p>&nbsp; </p>
</body>
</html>


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值