Dependent Dropdownlist (Ajax) Problem

Hello everyone, I am new in Yii and I need your help. I have a model called ‘Share’ and another one is ‘Usergroup’ which links only two different model ‘User’ and ‘Group’ by userId and groupId. However. I want to load a dropdownlist in the ‘Share’ view from the ‘Usergroup’ table/model using a condition which I have done. But now I have to load another dropdown/listdata (userid) based on input of first dropdown(groupId)from the table ‘usergroup’ but its not working. Please help me:

table:

Share: id, userId(fk), fileId(fk), …

Usergroup: id, userId(fk), groupId(fk) , …

Code:

View: Share : _form.php

<div class="row">

    &lt;?php echo &#036;form-&gt;labelEx(&#036;model,'Groups'); ?&gt;


    &lt;?php 


	&#036;id_tmp = Yii::app()-&gt;session['id'];


	echo &#036;form-&gt;dropDownList(&#036;model,'groupId',CHtml::listData(Usergroup::model()-&gt;findAll(array('condition'=&gt;&quot;userId='&#036;id_tmp'&quot;)), 'id', 'groupId'), array(


                                    'ajax' =&gt; array(


                                    'type'=&gt;'POST', //request type


                                    'url'=&gt;CController::createUrl('ShareCon'), //url to call.


                                    //Style: CController::createUrl('currentController/methodToCall')


                                    //'update'=&gt;'#' . CHtml::activeId(&#036;model, 'userId'), //selector to update


									'update'=&gt;'#userId' 


                                    //'data'=&gt;'js:javascript statement' 


                                    //leave out the data key to pass all form values through


                                    ))); ?&gt;     


									


	


	   


    &lt;?php echo &#036;form-&gt;error(&#036;model,'Groups'); ?&gt;


    &lt;/div&gt;


    


    &lt;div class=&quot;row&quot;&gt;


            &lt;?php echo &#036;form-&gt;labelEx(&#036;model,'Users'); ?&gt;


            &lt;?php echo &#036;form-&gt;dropdownList(&#036;model,'userId',array()); ?&gt;


            &lt;?php echo &#036;form-&gt;error(&#036;model,'Users'); ?&gt;


    &lt;/div&gt;


	











&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'fileId'); ?&gt;


	&lt;?php //echo &#036;form-&gt;textField(&#036;model,'fileId'); ?&gt;


	


	&lt;?php	


	echo Yii::app()-&gt;session['fileid'];


	?&gt;


	


	&lt;?php echo &#036;form-&gt;error(&#036;model,'fileId'); ?&gt;


&lt;/div&gt;

model: share.php

public $groupId, $grouid_1;

Controller: ShareController.php

public function actionShareCon()


{


    &#036;data=Usergroup::model()-&gt;findAll('id=:id', 


    array(':id'=&gt;(int) &#036;_POST['Share']['groupId']));





    &#036;data=CHtml::listData(&#036;data,'id','userId');


    foreach(&#036;data as &#036;value=&gt;&#036;userid)


    {


            echo CHtml::tag('option',


               array('value'=&gt;&#036;value),CHtml::encode(&#036;userId),true);


    }


}



public function actionShareCon()

{

$data=Usergroup::model()->findAll('id=:id',

array(':id'=>(int) $_POST['Share']['groupId']));


$data=CHtml::listData($data,'id','userId');

foreach($data as $value=>$userid)

{

echo CHtml::tag('option',

array('value'=>$value),CHtml::encode($userId),true);

}

} 



u may test with

echo something here




public function actionShareCon()

{

echo 'test';

} 



THanks a lot :) :) :)