手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >js 获取Listbox选择的值的代码
js 获取Listbox选择的值的代码
摘要:复制代码代码如下:functionGetValue(){varstrlist=document.getElementById("ListBo...

复制代码 代码如下:

<script type="text/javascript">

function GetValue() {

var strlist = document.getElementById("ListBox1");//获取Listbox

var str= "";

//遍历Listbox,取得选中项的值

if (strlist.options.length > 0) {

for (var i = 0; i < strlist.options.length; i++) {

if (strlist.options[i].selected == true) {

var j = strlist.options[i].value;

str+=j+","; //把Value值串起来

}

}

var strValue=str.replace(/,$/, ""); //去掉最后一个逗号

alert(strValue);

}

else {

alert("No Item in Listbox");

}

}

</script>

【js 获取Listbox选择的值的代码】相关文章:

判断file框选择的是否为图片

获得当前页面URL地址的三个JS代码

父窗口获取弹出子窗口文本框的值

解析Node.js基于模块和包的代码部署方式

JavaScript的while循环的使用

网页里控制图片大小的相关代码

光标的帖子总结(Range的使用)

js获取滚动距离的方法

javascript获取select值的方法分析

VBScript版代码高亮

精品推荐
分类导航