Solved

Get selected value of RadioButtonList using JQuery

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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…

710 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