0

我有一个复选框列表CHtml::checkBoxList,我需要一个带有“全选”的复选框,以便在选中时选中所有复选框。但我不知道该怎么做。

4

1 回答 1

0

你可以做

<?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')) ?>
于 2014-05-05T10:41:54.107 回答