I have a checkboxlist control in one of the web application. I want to use javascript to handle the SelectedIndexChanged event.
The checkbox list is like
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
<asp:ListItem>Three</asp:ListItem>
<asp:ListItem>Four</asp:ListItem>
<asp:ListItem>Five</asp:ListItem>
</asp:CheckBoxList>
How can I get the SelectedIndexChanged event using javascript?
I have a checkboxlist control in one of the web application. I want to use javascript to handle the SelectedIndexChanged event.
The checkbox list is like
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
<asp:ListItem>Three</asp:ListItem>
<asp:ListItem>Four</asp:ListItem>
<asp:ListItem>Five</asp:ListItem>
</asp:CheckBoxList>
How can I get the SelectedIndexChanged event using javascript?
Share Improve this question edited Mar 20, 2012 at 3:42 Joseph 120k30 gold badges184 silver badges237 bronze badges asked Mar 20, 2012 at 3:40 MithunRajMithunRaj 1034 silver badges12 bronze badges2 Answers
Reset to default 5On server side.. put the follwoing..
CheckBoxList1.Attributes.Add("onclick", "ChangeCheckBox();");
In client side JavaScript section, implement the following function
function ChangeCheckBox() {}
you can use below code
document.getElementById('CheckBoxList1').onchange = function () {
var input = document.getElementById('CheckBoxList1').getElementsByTagName("input")
for (var i = 0; i < input.length; i++) {
if (input[i].type == "checkbox") {
if (input[i].checked == true) {
alert(input[i].value);//Get all the checked checkboxes
}
}
}
}