Home > ASP.Net, Javascript, Jquery > JQuery to Select CheckBoxes in Checkboxlist

JQuery to Select CheckBoxes in Checkboxlist


Hi all ,

try this example to use JQuery to Select CheckBoxes in Checkboxlist


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
 <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.js" type="text/javascript"></script>
 <script type="text/javascript">
 $(document).ready(function () {
 $($('#<%=values.ClientID %>').val().split(",")).each(function (i, item) {
 $("table[id*=CheckBoxList1] input[value=" + $.trim(item) + "]").attr('checked', true);
 });
 });
</script>
</head>
<body>
 <form id="form1" runat="server">
 <asp:HiddenField ID="values" runat="server" Value="1, 2, 4" />
 <asp:CheckBoxList ID="CheckBoxList1" runat="server">
 <asp:ListItem Text="Text1" Value="1"></asp:ListItem>
 <asp:ListItem Text="Text2" Value="2"></asp:ListItem>
 <asp:ListItem Text="Text3" Value="3"></asp:ListItem>
 <asp:ListItem Text="Text4" Value="4"></asp:ListItem>
 </asp:CheckBoxList>
 </form>
</body>
</html>

Hope this helps

Good Luck.

Advertisements
Categories: ASP.Net, Javascript, Jquery
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: