通过js获取select(多选下拉)中所选值
来源:互联网 发布:腾讯云域名续费 编辑:程序博客网 时间:2024/05/17 01:11
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<script language="JavaScript">
<!--
function checkselect(){
var x = document.getElementById("objsel");
var t = document.getElementById("output");
var count=0;
var intvalue="";
for(i=0;i<x.length;i++){
if(x.options[i].selected){
intvalue+=x.options[i].value+",";
count++;
}
}
t.value=intvalue.substr(0,intvalue.length-1);
alert(count);
}
//-->
</script>
<select id="objsel" 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();" value="输出">
选中的项目:<input type="text" id="output" name="output">
</body>
</html>
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<script language="JavaScript">
<!--
function checkselect(){
var x = document.getElementById("objsel");
var t = document.getElementById("output");
var count=0;
var intvalue="";
for(i=0;i<x.length;i++){
if(x.options[i].selected){
intvalue+=x.options[i].value+",";
count++;
}
}
t.value=intvalue.substr(0,intvalue.length-1);
alert(count);
}
//-->
</script>
<select id="objsel" 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();" value="输出">
选中的项目:<input type="text" id="output" name="output">
</body>
</html>
0 1
- 通过js获取select(多选下拉)中所选值
- JS 获取select (多选下拉)中所选中的值
- document.all用法+js获取select标签中所选的值
- js获取select下拉选框自定义属性的值
- 如何利用jquery获取下拉框中所选的内容以及select里value的使用
- js获取下拉列表选中项的值和文本(select)以及获取单选按钮
- js获取select下拉框的值
- 【Bootstrap Table】在指定列中添加下拉框控件,并获取所选值
- JS设置下拉列表框当前所选值
- Bootstrap-select下拉多选获取选中的数据
- js获取select 下拉列表中的所有值
- JS获取select下拉列表框选中的值
- js,jq获取select下拉框的各项值
- js中select控件不能通过getElementById来获取。
- js获取下拉选的值
- 记录:ajax获取数据动态生成select下拉选js部份
- Jquery 获取多选下拉列表select multiple的文字和值 text val
- javascript如何获取select下拉框中显示的值
- C++面试中string类的一种正确写法
- 如何计算两个文档的相似度(二)
- ExtJS数据模型Model和代理proxy
- iPhone Configuration Utility 下载
- 《软件方法上册》读后感
- 通过js获取select(多选下拉)中所选值
- java基础知识点
- WIN7无签名驱动解决方法
- eclipse如何开启智能提示
- Redis的简介及安装
- 【Cracking the coding interview】Q1.4(变位词)
- evasi0n announced about Chinese jailbreak supermarket
- atheros无线驱动之:ACL黑白名单
- Service属性简介