獲取CheckBoxList選中項的Text值
阿新 • • 發佈:2019-02-12
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);
}
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);
}