Link to home
Start Free TrialLog in
Avatar of jeffhodgeson
jeffhodgeson

asked on

Get selected value of RadioButtonList using JQuery

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

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Avatar of jeffhodgeson
jeffhodgeson

ASKER

Thanks, just what I was looking for.
you're welcome