Solved

jquery issue with radio buttons

Posted on 2014-07-30
5
246 Views
Last Modified: 2014-07-30
Hi I want to do the work which is done on radio button click  in button(named Button1) click, kept blank below, Please help

 <script type="text/javascript">

         $(document).ready(function () {
             $(".myRadios").bind("click", function () {          

                 alert($(this).val());
           
                 alert($(this).closest("td").next("td").html());
                 alert($(this).closest("td").next("td").next("td").html());
             });

            $(".btncss").bind("click", function () {

             });
       });

     </script>
     <div id="abc">
         <br />
         <br />
         <table id="tbl">
             <tr>
                 <td>
                     <input class="myRadios" name="abc1" id="abc1" type="radio" value="1" /></td>
                 <td>11</td>
                 <%--<td>22</td>--%>
             </tr>
             <tr>
                 <td>
                     <input class="myRadios" name="abc1" id="abc1" type="radio" value="2" /></td>
                 <td>22</td>
                 <td>33</td>
             </tr>
             <tr>
                 <td>
                     <input class="myRadios" name="abc1" id="abc1" type="radio" value="3" /></td>
                 <td>33</td>
                 <td>44</td>
             </tr>
             <tr>
                 <td>
                     <input class="myRadios" name="abc1" id="abc1" type="radio" value="4" /></td>
                 <td>44</td>
                 <td>55</td>
             </tr>
         </table>
         <input id="Button1" type="button" value="button" class="btncss" />
     </div>

Open in new window

0
Comment
Question by:Dinesh Kumar
  • 3
  • 2
5 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40229502
If I understand just disable the button in the onclick function

$("#Button1").attr("disabled",true)
0
 

Author Comment

by:Dinesh Kumar
ID: 40229514
the problem is that whenever I click on Button1

I will check if radio button is selected then I want to pick values from corresponding two <td>s

e.g if I select second radio button and then press the Button1 then corresponding td are  <td>22</td>                <td>33</td> I should be able to get those values.
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40229544
http://jsfiddle.net/GaryC123/C4eQB/

$(document).ready(function () {
    $("#Button1").click(function () {
        if ($(".myRadios").is(':checked')) {
            el = $(".myRadios:checked").closest("td").next("td")
            alert(el.html());
            alert(el.next("td").html());
        }
    });
});

Open in new window

0
 

Author Closing Comment

by:Dinesh Kumar
ID: 40229581
Thank you very much!!
0
 

Author Comment

by:Dinesh Kumar
ID: 40229583
It worked like a bolt :)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question