If you want to iterate through Checkboxlist check box items it not as straightforward as you might have thought.
The trick is to access the check box items rendered as labels as shown below
var chkBoxList = document.getElementById('<%=chkList.ClientID%>');
var checkboxes = chkBoxList .getElementsByTagName('input');
for (var i = 0; i < checkboxes .length; i++) {
var checkItem = checkboxes [i];
var label = checkItem .parentNode.getElementsByTagName('label');
//checked item
if (checkItem .checked) {
...
}
//access checkItem text
label[0].innerHTML='';
}
}
cheers
Samitha
The trick is to access the check box items rendered as labels as shown below
var chkBoxList = document.getElementById('<%=chkList.ClientID%>');
var checkboxes = chkBoxList .getElementsByTagName('input');
for (var i = 0; i < checkboxes .length; i++) {
var checkItem = checkboxes [i];
var label = checkItem .parentNode.getElementsByTagName('label');
//checked item
if (checkItem .checked) {
...
}
//access checkItem text
label[0].innerHTML='';
}
}
cheers
Samitha