`
zjx2388
  • 浏览: 1306677 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

获取select 中有multiple属性,获取选中的值

阅读更多
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
 <head>
  <title> New Document </title>
 </head>

 <body>

<script language="JavaScript">
  <!--
function checkselect(objname){
	o = document.getElementById(objname);
	t = document.getElementById("output");
	var intvalue="";
	for(i=0;i<o.length;i++){   
		if(o.options[i].selected){
			intvalue+=o.options[i].value+",";
		}
	}
	t.value=intvalue.substr(0,intvalue.length-1);
}
  //-->
  </script>
  <select name="objsel" size=8 multiple>
	<option value="0" selected>请选择...
	<option value="1">测试一
	<option value="2">测试二
	<option value="3">测试三
	<option value="4">测试四
	<option value="5">测试五
  </select>
<input type="button" onclick="checkselect('objsel');" value="输出">
选中的项目:<input type="text" name="output">
 </body>
</html>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics