in view page i have 2 dropdown
<?php
$list = CHtml::listData($category,
'cid', 'cname');
echo $form->dropDownList($model,'cid',$list,
array('empty' => '(Select a category)'));
?>
<label>Sub Category *</label>
<?php
$subcategory = array();
echo $form->dropDownList($model,'sid',$subcategory,
array('empty' => '(Select a subcategory)'));
?>
Using value from category i have to change subcategory values
Here is my ajax function
<script type="text/javascript">
$(function (){
$("#Product_cid").change(function (){
var cid = $('#Product_cid').val();
var path = "<?php echo $this->createUrl('admin/mysubcategory') ?> ";
$.ajax({
type: "POST",
url: path, //url to be called
data: { cid: cid } //data to be send
}).done(function( msg ) {
alert(msg)
$("#Product_sid").val("msg");
$("#Product_sid").selectmenu('refresh');
.
});
});
});
</script>
And here is my controller
public function actionMysubcategory()
{
$cid = Yii::app()->request->getPost('cid');
$subcategory= Subcategory::model()->findAll(
array('order'=>'sid',
'condition'=>'cid=:cid',
'params'=>array(':cid'=>$cid)));
$list = CHtml::listData($subcategory,
'sid', 'sname');
print_r($list);
}

I gets list from controller. How can make into a dropdown???
alert(msg)...