jQuery to select/deselect all items in a CheckBoxList.

Posted by vishalneeraj-24503 under jQuery category on | Points: 40 | Views : 344

<asp:CheckBox runat="server" ID="selectAllCb" Text="Select All" />
<asp:checkboxlist runat="server" ID="containerCBL">

<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>

<script type="text/javascript">
//hook to the document ready function
$(document).ready(function ()
//find the select all checkbox
var selectAll = $('#<%=selectAllCb.ClientID%>');

//hook onto select all checkbox's click event
function ()
//for all input types of checkbox
//for the container
//set the attribute to the value
//of select all checkbox
$("#<%=containerCBL.ClientID%> input[type='checkbox']").
attr('checked', selectAll.is(':checked'));

Comments or Responses

Login to post response