?
Solved

jquery issue with radio buttons

Posted on 2014-07-30
5
Medium Priority
?
252 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
Suggested Courses

765 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