I have checkBoxList
<asp:CheckBoxList ID="cheBoxTypeOfInc" runat="server" onchange="checkBoxchanged()" CssClass="form-checkbox" Height="39px" Width="493px" RepeatDirection="Horizontal" RepeatColumns="1">
<asp:ListItem Value="CommMotVehiAcci">Commercial Motor Vehicle Accident</asp:ListItem>
<asp:ListItem Value="EmpInjry">Employee Injury </asp:ListItem>
</asp:CheckBoxList>
and I am adding more Item to it as addElement("InciRepo", "Incident Reporting");
and defination of addElement is as below :
function addElement(a, b) {
var tableRef = document.getElementById('<%= cheBoxTypeOfInc.ClientID %>');
var tableRow = tableRef.insertRow();
var tableCell = tableRow.insertCell();
var checkBoxRef = document.createElement('input');
var labelRef = document.createElement('label');
checkBoxRef.type = 'checkbox';
checkBoxRef.id = a;
labelRef.innerHTML = b;
checkBoxRef.value = a;
tableCell.appendChild(checkBoxRef);
tableCell.appendChild(labelRef);
}
I want to read the selected value using Javascript as
function checkBoxchanged()
{
debugger;
var chebox = document.getElementById('<%= cheBoxTypeOfInc.ClientID %>');
var checkboxesChecked = [];
// loop over them all
for (var i = 0; i < checkboxes.length; i++) {
// And stick the checked ones onto an array...
if (checkboxes[i].checked) {
checkboxesChecked.push(checkboxes[i]);
}
}
but its not giving me list. In fact when i am looking for the selected item its not showing checked also. is i am missing something ? is there any other way to active this ? Please advice !!