Select All Radio Buttons, Except for Disabled Ones

Select All Radio Buttons, Except for Disabled Ones

kraftomatickraftomatic Posts: 78Questions: 13Answers: 0
edited April 2012 in General
Hey Allan,

I have this function you helped me with:

table.$('tr').each( function () {
$('input:eq('+(index+1)+')', this).attr('checked', true).change();
} );

I'm trying to add a simple logic check, so that if the radio button is disabled, it will not be selected. I believe I want to use the :disabled filter, and I think it can be used cleanly within one line (without an if/else check), but I'm not sure the best way to do it.

Any suggestions?

Thanks.

Replies

  • allanallan Posts: 63,810Questions: 1Answers: 10,516 Site admin
    I think the best way is to use the jQuery filter() method: http://api.jquery.com/filter/

    [code]
    $('input:eq('+(index+1)+')', this).filter(':not(:disabled)').attr('checked', true).change();
    [/code]

    ( not actually tested, but I think it should work :-) )

    Allan
  • kraftomatickraftomatic Posts: 78Questions: 13Answers: 0
    Brilliant. Thank you yet again Allan. :)
This discussion has been closed.