views:

33

answers:

1

I need to problematically (do you mean programmatically?) check a radio button given its value. The form has an id and the input type obviously has a name (but no id). The only code I managed to get working so far is:

$('input[name=my_name]:eq(1)').attr('checked', 'checked');

But I'd like to be able to check it by explicitly providing the value.

+1  A: 

So you want to select the radio which has a particular value:

$('input[name=my_name][value=123]').attr('checked', true); // or 'checked'
nickf