views:

175

answers:

1

Hello,

I'm using a form with checkboxes from jQuery UI and I'm having some problems with them :

here is my code : php

<input type="checkbox" id="check'. $empl->getAttr('id') .'" class="intervenants" /><label for="check'. $empl->getAttr('id') .'">'.$empl->getAttr('nom').'</label>';

javascript

$('.intervenants').each(function() {
    $(this).attr('checked',false);
   });
   for(i = 0; i < data.list_empl.length; i++) {
    $('#check'+data.list_empl[i].id).attr('checked',true);
   }

I want, as you can see, uncheck all the checkboxes, then I look in my array and try to check only the checkboxes existing in my array. The problem is that it doesn't work...

I don't know what doesn't work, I've tried to put alert, to look in html but it looks like it's totall incoherent.

I would really appreciate your help, thanks in advance,

Luca.

+1  A: 

To check a checkbox:

$(selector).attr('checked', 'checked');

To uncheck a checkbox:

$(selector).removeAttr('checked');
Oren Trutner