Click here to Skip to main content
15,894,410 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
hi...

in aspx.cs page i have created dynamic string builder including checkbox. If i select those check box n click a button it will redirect in a new page...how will i get selected check box id in jquery...???

please help me out...
Posted

1 solution

Hi Try this code...
Dont forget to include the jquery file reference..


XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="JQuery.js" type="text/javascript"></script>

      <script type="text/javascript">
          $(function () {

              $('#Button1').click(function () {

                  var ids = '';
                  $('input:checked').each(function () { ids += this.id + ',' });
                  alert(ids);


                  window.location.href = 'url_you_want_to_navigate?ids=' + ids;

                  return false;

              });


          });



      </script>


</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CheckBox ID="CheckBox1" runat="server" />
        <asp:CheckBox ID="CheckBox2" runat="server" />
        <asp:CheckBox ID="CheckBox3" runat="server" />
        <asp:CheckBox ID="CheckBox4" runat="server" /><asp:Button ID="Button1" runat="server"
            Text="Button" />
    </div>
    </form>
</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900