您的位置:首页 > 其它

获取CheckBoxList选中项的Text值

2016-11-15 10:02 295 查看
function getSelectedUser() {

                var strReturn = "";

            var CheckBoxList = document.getElementById("<%=cblNextUser.ClientID %>");

            if (CheckBoxList.tagName == "TABLE") {

                for (i = 0; i < CheckBoxList.rows.length; i++)

                    for (j = 0; j < CheckBoxList.rows[i].cells.length; j++)

                        if (CheckBoxList.rows[i].cells[j].childNodes[0])

                            if (CheckBoxList.rows[i].cells[j].childNodes[0].checked == true) { 

                                if(strReturn!="")strReturn+=",";

                                strReturn+=CheckBoxList.rows[i].cells[j].childNodes[1].innerText;

                            }

            }

            if (CheckBoxList.tagName == "SPAN") {

                for (i = 0; i < CheckBoxList.childNodes.length; i++)

                    if (CheckBoxList.childNodes[i].tagName == "INPUT")

                        if (CheckBoxList.childNodes[i].checked == true) {

                            if (strReturn != "") strReturn += ",";

                            strReturn += CheckBoxList.rows[i].cells[j].childNodes[1].innerText;

                        }

                    }

                    alert(strReturn);

        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: