首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么用javascript获取CheckBoxList中选中的值

2012-01-11 
如何用javascript获取CheckBoxList中选中的值在线等,问题解决分全给--------functionadd(){varownerdocum

如何用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;
}

热点排行