Solved

jquery issue with radio buttons

Posted on 2014-07-30
5
244 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn how to dynamically set the form action using jQuery.
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…

815 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now