Reputation: 1104
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.
Upvotes: 0
Views: 3472
Reputation: 41
To get this working with jQuery UI you have to use:
$(selector).checkBox('changeCheckStatus',true);
$(selector).checkBox('changeCheckStatus',false);
Upvotes: 4
Reputation: 24208
To check a checkbox:
$(selector).attr('checked', 'checked');
To uncheck a checkbox:
$(selector).removeAttr('checked');
Upvotes: 2