Solved

Get selected value of RadioButtonList using JQuery

Posted on 2012-12-31
4
430 Views
Last Modified: 2012-12-31
The function below works fine.  But I was curious as to how to use 'this' with the input:checked selector to find the value of the checked button.  I've tried different formats but haven't hit on the right one. i.e. $('this input:checked').val()

$(function () {
    $('#<%=rblExistingDamage.ClientID%>').click(function () {
        if ($('#<%=rblExistingDamage.ClientID%> input:checked').val() == 'true') {
             $('#<%=rowExistingDamage.ClientID%>').show();
         } else {
            $('#<%=rowExistingDamage.ClientID%>').hide();
        }
    });
});

Open in new window

0
Comment
Question by:jeffhodgeson
  • 3
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 38733071
replace : $('#<%=rblExistingDamage.ClientID%> input:checked')
by : $('input:checked', this)

or

replace : $('#<%=rblExistingDamage.ClientID%> input:checked')
by : $(this).find('input:checked')
0
 
LVL 82

Expert Comment

by:leakim971
ID: 38733077
or replace :
    $('#<%=rblExistingDamage.ClientID%>').click(function () {
        if ($('#<%=rblExistingDamage.ClientID%> input:checked').val() == 'true') {
             $('#<%=rowExistingDamage.ClientID%>').show();
         } else {
            $('#<%=rowExistingDamage.ClientID%>').hide();
        }
    });

Open in new window

by :
    $(":radio", '#<%=rblExistingDamage.ClientID%>').change(function () {
        if ($(this).is(":checked") && $(this).val() == 'true') {
             $('#<%=rowExistingDamage.ClientID%>').show();
         } else {
            $('#<%=rowExistingDamage.ClientID%>').hide();
        }
    });

Open in new window

0
 

Author Closing Comment

by:jeffhodgeson
ID: 38733444
Thanks, just what I was looking for.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 38733451
you're welcome
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add a 3rd selection to sum 7 29
jquery datatables, asp.net MVC 9 41
Error handling in asp.net site 5 29
Convert Select to DropDownListFor MVC 5 2 16
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…

803 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