0

I have some Radio Buttons that creates in run time and they are inside of a table.How I can check that one of the surly selected using jQuery?

Thanks

2
  • Using tables for layout, aren't we? :) Commented Nov 5, 2011 at 12:37
  • Are the radio buttons part of the same radio button group? Commented Nov 5, 2011 at 12:39

2 Answers 2

1

you can try like this....

 $('#table tbody tr input[type=radio]').each(function(){
     alert($(this).attr('checked'));
    });

or

There are many ways to do that, e.g., using .each and the .is traversal method:

$("table tr td input[name=something]:radio").each(function() {
    if($(this).is(":checked")) {
        $(this).closest("tr").css("border", "1px solid red");
    } else {
        // do something else
    }
});

or you can do like this .....

define a class on your radio button items, basically your client side HTML should look like <input id="answer-2_1" type="radio" name="answer-2" value="0" class="myrdo" />

now, in your js code, simply wire up an event handler on the class

$(".myrdo").bind("click",function(){if($(this).attr("checked")==true) {alert($(this).val);} });

the above command will simply alert the value of the selected radio button.

Sign up to request clarification or add additional context in comments.

Comments

0

A general solution:

if ( $( 'input[type="radio"]', '#table' ).is( ':checked' ) ) {
    // validation passes
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.