Solved

Get selected value of RadioButtonList using JQuery

Posted on 2012-12-31
4
426 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Name space syntax error 12 44
Host asp.net pages 5 26
ASP.NET 5 Templates 2 68
Importing CSV file encoded in UTF-8 in SQL SERVER 2008 using BULK INSERT 5 31
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…

863 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

20 Experts available now in Live!

Get 1:1 Help Now