select控件问题?

marksmile 2004-12-01 12:01:38
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css/style1.css" rel="stylesheet" type="text/css">
</head>

<body>
<!--include top.jsp begin-->
<%@ include file="top.jsp"%>
<!--include top.jsp end-->
<!--include menu.jsp begin-->
<%@ include file="menu.jsp"%>
<!--include menu.jsp end-->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="31" background="images/btl_bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="btlfirst">
<tr>
<td width="30"> </td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"><img src="images/arrow2.gif" width="9" height="8"></td>
<td class="btlfirst">编辑项目</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodycon">
<tr>
<td width="12" valign="top" background="images/body_leftbg.gif"><img src="images/body_left.gif" width="12" height="428"></td>
<td valign="top" class="bodycon"><br>
<br> <table border="0" align="center" cellpadding="0" cellspacing="0" class="input1">
<tr>
<td class="inputtitle"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/button_left.gif" width="10" height="24"></td>
<td background="images/button_bg.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center"><img src="images/icon_submit.gif" width="11" height="14"></td>
<td>提交</td>
</tr>
</table></td>
<td><img src="images/button_right.gif" width="10" height="24"></td>
</tr>
</table></td>
<td> </td>
<td><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/button_left.gif" width="10" height="24"></td>
<td background="images/button_bg.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center"><img src="images/icon_reset.gif" width="13" height="12"></td>
<td>重置</td>
</tr>
</table></td>
<td><img src="images/button_right.gif" width="10" height="24"></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" align="center" cellpadding="4" cellspacing="0">
<tr>
<td width="15%" align="center" class="inputunderline"><font color=red>*</font>使用语种</td>
<td class="inputunderline"><select name="select3" size="5" multiple="multiple">
<option value="1">中文</option>
<option value="2">英语</option>
<option value="3">日文</option>
</select></td>
</tr>
</table></td>
</tr>
</table>
<br></td>
</tr>
</table>
<!--include bottom.jsp begin-->
<%@ include file="bottom.jsp"%>
<!--include bottom.jsp end-->
</body>
</html>


如何实现语种的多选?(如果选择英语和中文的话,提交表单时应该得到1和2)
...全文
90 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
butcher2002 2004-12-01
  • 打赏
  • 举报
回复
<select name="select3" size="5" multiple="multiple">
<option value="1,2">中文</option>
<option value="1,2">英语</option>
<option value="3">日文</option>
</select></

这样不就可以了?
cloudside 2004-12-01
  • 打赏
  • 举报
回复
你本页什么也不用改,这个就像checkbox一样,在提交到下一页后,如果是jsp的话
<%
String[] str = request.getParameterValues( "language" );
if(str!=null&&str.length>0){
for(int i=0; i<str.length; i++){
out.println(str[i]);

}
}
%>
你会得到一个string数组,会得到所有选取的值
shyslysky 2004-12-01
  • 打赏
  • 举报
回复
<body>
<form name =f>
<select id="s" size="5" multiple>
<option value="1">中文</option>
<option value="2">英语</option>
<option value="3">日文</option>
</select>
<input type=text name=t1><!--存放想要的值-->
<input value=test type=button onclick="test()">
</body>

<SCRIPT>
function test(){
var opts=document.f.s.options
var str=""
for(var i=0;i<opts.length;i++)
if(opts[i].selected)
str+=opts[i].value+","
document.f.t1.value=str
}

</SCRIPT>
marksmile 2004-12-01
  • 打赏
  • 举报
回复
这个不是解决问题的方法,如果我选中文和日文呢

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧