如何用javascript获取CheckBoxList中选中的值
在线等,问题解决分全给
--------
function add()
{
var owner = document.getElementById( "ListBox3 ");
if (!owner || owner.disabled)
return false;
var element;
var i = 0;
while (element = document.getElementById( "ListBox3 " + "_ " + (i++)))
{
alert(element.value);
if (!element.disabled)
element.checked = true;
}
return false;
}
--------------
ListBox3是CheckBoxList的ID名称
这是全选的功能,但不知道获取它选中的值
------解决方案--------------------CheckBoxList在客户端没有value值
你可以参考
http://topic.csdn.net/t/20051124/13/4415350.html
------解决方案--------------------function getChecked()
{
var owner = document.getElementById( "ListBox3 ");
if (!owner || owner.disabled)
return false;
var element;
var i = 0;
var n = 0;
var resultArray = new Array();
while (element = document.getElementById( "ListBox3 " + "_ " + (i++)))
{
alert(element.value);
if (!element.disabled)
resultArray[n++] = element.Id;
}
return resultArray;
}