0

I have a checkboxlist using CHtml::checkBoxList and I need a checkbox with 'Select all' to select all checkboxes when it is checked. But I don't know how to do it.

halfer
  • 19,824
  • 17
  • 99
  • 186
hd.
  • 17,596
  • 46
  • 115
  • 165

1 Answers1

0

You could do

<?php echo CHtml::checkBox('select_all',false, array('onclick' => "js:if($(this).is(':checked')) {$('.example').attr('checked','checked');}else{$('.example').removeAttr('checked');}")) ?>
<?php echo CHtml::activeCheckBoxList($model, 'items',array('example1','example2','example3'), array('class'=>'example')) ?>
Boontjie
  • 31
  • 2