Adding Ajax Functionality To The Chtml::checkboxlist

Hi all i want to add the ajax functionality to the CHtml::checkBoxList,

my code is,

<?php echo CHtml::label(‘State’ ,’’); ?>

 &lt;?php echo CHtml::checkBoxList(


		'state_name',


		array(0),


		CHtml::listData(State::model()-&gt;findAll(),'id','state_name'),


		array('checkAll'=&gt;'Select all States', 'checkAllLast'=&gt;false,'container'=&gt;'ul','ajax' =&gt; array(


			'type'=&gt;'POST', 


			'url'=&gt;CController::createUrl('MyController/SetDistrict'),


			


			'update'=&gt;'#district_name',


		))


);  ?&gt;

In this ajax works,but the problem is if i click on the check box it is not selected or deselected…can any one give me the right suggession…!

hi,

sample code to include the query function

echo $form->dropDownList($yourmodel,‘yourfieldtolink’, $yourresultset, array(‘empty’ => ‘-- Select–’, ‘style’ => ‘width:150px;’, “onChange” => “yourajaxfunction(optionalparams)”, “disabled” => ‘false’));

Hi, kumarkulandai

You mean like this

<?php echo CHtml::label(‘State’ ,’’); ?>

<?php echo CHtml::checkBoxList(

‘state_name’,

array(0),

CHtml::listData(State::model()->findAll(),‘id’,‘state_name’),

array(‘checkAll’=>‘Select all States’, ‘checkAllLast’=>false,‘container’=>‘ul’,“onChange”=>‘ajax’ => array(

‘type’=>‘POST’,

‘url’=>CController::createUrl(‘MyController/SetDistrict’),

‘update’=>’#district_name’,

))

); ?>

i think it won’t work.

You can set ‘return’=>true in the html options to force returning true or non-false value.