here’s the code in my controller
public function actionUpdatesubcat()
{
$data = subcat::model()->findAll('MAINCATID=:parent_id',
array(':parent_id'=>(int)$_POST['MAINCATID']));
$data = CHtml::listData($data,'SUBCATID','SUBCAT');
foreach($data as $key => $value)
{
echo CHtml::tag('option',array('value'=>$key),CHtml::encode($value),true);
}
}
and here’s the code in my view
<tr>
<td>Category:</td>
<td><?php
$listdata = CHtml::listdata($categories,'MAINCATID','MAINCAT');
echo CHtml::dropDownList('MAINCATID', 'MAINCAT', $listdata,
array(
'ajax'=>array(
'type'=>'POST',
'url'=>CController::createUrl('mycontroller/updatesubcat'),
'update'=>'#subcatdrop'
)));
?>
</td>
<td>Sub-Category:</td>
<td> <?php echo CHtml::dropDownList('subcatdrop',$subcat,array('empty'=>'--SELECT--'));?></td>
</tr>
when i select from that drop down listings and then submit the page…the drop down list was like rubber that it goes to the default selected option after the page refresh…how to solve this ?