tags:

views:

225

answers:

3

Hi, here's what i want to achieve:

  1. Have a grouped radio button with different values
  2. Selected radio will reveal specified div $('#group1').Show() & $('#group2').Hide()

My question is: How do I do get the value of the selected radiobutton from the group?

+1  A: 
$("input[name=GroupName]:checked").val();
Philippe Leybaert
A: 

You can use the :checked selector, e.g.:

$('input[name=selector]:checked').val()
Matt Good
nice, thanks! ill try this one
Martin Ongtangco
A: 

im having problems here, mind if you check my codes? Thanks!

$("input:radio[@name='searchOption']").click(function() {
        var choice = $("input:radio[@name='searchOption']:checked").val();
        switch (choice) {
            case 'Recent':
                $('#patient_Form').show();
                break;
            case 'Search':
                $('#patient_Form').hide();
                break;
            case 'Add':
                $('#patient_Form').hide();
                break;
        }
    });
Martin Ongtangco