salam mastaa,
saya punya checkbox berikut code nyah :
<?php
$this->breadcrumbs=array('dwtraday');
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$.fn.yiiGridView.update('dwtraday-grid', {
data: $(this).serialize()
});
return false;
});
");
echo CHtml::beginForm("index.php?r=report/dwtraday", "post", array("id"=>"myForm"));
?>
<table class="multiple">
<tr><th>
<?php
echo CHtml::ajaxButton('Search',CController::createUrl('report/checkboxUpdate'));
?>
</th></tr>
<tr> <th>
<?php echo CHtml::activeCheckBox($form, false, array ("class" => "checkAll")). ' '. "All"; ?>
</th> </tr>
<?php foreach($conn->schema->getTable('dbo.DW_TRA_DAY')->getColumnNames() as $key => $raw){ ?>
<?php if ($key % 5 == 0) { ?>
<tr>
<?php } ?>
<th><?php echo CHtml::checkbox($form, false, array("id"=>$raw, "value"=>"submit")) . ' ' . $raw; ?></th>
<?php if ($key % 5 == 4) { ?>
</tr>
<?php } ?>
<?php } ?>
</table>
<?php echo CHtml::endForm(); ?>
</br>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial("_dwtraday",array(
"model"=>$model,
)); ?>
</div>
nah <script language="javascript">
$(document).ready(function(){
//var field = document.getElementById($raw);
// powerful jquery ! Clicking on the checkbox 'checkAll' change the state of all checkbox
$('.checkAll').change(function () {
$("input[type='checkbox']").attr('checked', this.checked);
});
});
nah function checkall nyah jalan, cuma saya ga ngerti dptin checkbox id=$raw buat difunction js nya…
bisa ga saya tambah js function di checkbox nya, mungkin yg kaya begini tpi saya ga tw yg bener nyah mesti gmn hehehehh
<?php echo CHtml::checkbox($form, false, array("id"=>$raw, "value"=>"submit" "option"=>"js:('checked', this.checked)")) . ' ' . $raw; ?>
mohon saran nya
owh iyah saya tidak menggunakan $model tapi $form = new PolymorphicForm;
for detail PolymorphicForm