<asp:CheckBoxList ID="chkListMY" runat="server" RepeatColumns="1"> <asp:ListItem Text="" Value=""></asp:ListItem> </asp:CheckBoxList> success: function (data) {if (data.length){ var repeatColumns = parseInt("<%=chkListMY.RepeatColumns%>"); var cell = $("[id*=chkListMY] td").eq(0).clone(true); $("[id*=chkListMY] tr").remove(); for (var i = 0; i < data.length; i++) { var row = $("<tr />"); $("[id*=chkListMY] tbody").append(row); var checkbox = $("input[type=checkbox]", cell); //Set Unique Id to each CheckBox. checkbox[0].id = checkbox[0].id.replace("0", i); //Give text to each CheckBox. checkbox[0].text = data[i].Text //Set the CheckBox value. checkbox.val(data[i].Value); var label = cell.find("label"); if (label.length == 0) { label = $("<label />"); } //Set the 'for' attribute of Label. label.attr("for", checkbox[i].id); //Set the text in Label. label.html(data[i].Text); //Append the Label to the cell. cell.append(label); //Append the cell to the Table Row. row.append(cell); cell = $("[id*=chkListMY] td").eq(0).clone(true); }; } }
<script type="text/javascript"> $(document).ready(function () { getMonthYearCheckIndexChange(); </script> function getMonthYearCheckIndexChange() { $("[id*=chkListMY] input[type=checkbox]").click(function () { var chks = $("[id*=chkListMY] input[type=checkbox]"); var str = ""; for (var i = 0; i < chks.length; i++) { if (chks[i].checked) { str = str + chks[i].text + ','; } } str = str.substr(0, str.length - 1); alert(str); }); }
it initially shows empty check box in checkboxlist but my requirement is ,it(empty check box) should not be show. And When I checked any checkbox it is working means calling given function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)