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.
0
votes
1 Answers
0
votes
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')) ?>