多选的“卷动选单”怎样取得选中的每个值??

yeah920 2004-01-12 06:09:56
这样的一个多选下拉框:
<form name=fm action="" method="post">
Where you com from?
<select name="where" multiple>
<option value="hk">Hong Kong</option>
<option value="tw">Taiwan</option>
<option value="cn">China</option>
<option value="us">United States</option>
<option value="ca">Canada</option>
</select>
</form>
如果我点了多个(比如点了Hong Kong 和 Taiwan),怎样取得我选的值(hk和tw)??
...全文
55 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
寒冬 2004-01-12
  • 打赏
  • 举报
回复
String[] name=(String[])request.getParameterValues("where");


for(int i=0;i<name.length;i++)
{
out.println(name[i]+"yyyyyyy");
}
dengyin2000 2004-01-12
  • 打赏
  • 举报
回复
request.getParameterValues("where") 取到的是一个数组
dengyin2000 2004-01-12
  • 打赏
  • 举报
回复
String where="";
for(int i=0;i<request.getParameterValues("where").length;i++)
{
where=where+request.getParameterValues("where")[i]+",";
}
where=where.substring(0,xuanze.length()-1);
取得的值为 hk,tw

81,092

社区成员

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

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