Created
November 18, 2014 09:29
-
-
Save cjfarrelly/2628c786f4a5af5a48d7 to your computer and use it in GitHub Desktop.
Javascript function to check/uncheck all checkboxes in a checkboxlist, this also allows for normally functionality
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cblNamesChecked(event) { | |
var checkBoxList = document.getElementById("<%=cblNames.ClientID %>"); | |
var checkBoxes = checkBoxList.getElementsByTagName("input"); | |
event = event || window.event; | |
var target = event.target || event.srcElement; | |
if (target.id == "cblNames_0") { | |
for (var i = 0; i < checkBoxes.length; i++) { | |
checkBoxes[i].checked = target.checked; | |
} | |
} | |
} | |
<asp:CheckBoxList ID="cblNames" runat="server" CellPadding="0" OnClick="cblNamesChecked(event)" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment