My dependent dropdown list is not working!

Hi! I’ve got a problem, I was hoping if you could give me some insight. I have 2 dropdown boxes. I wanted to filter the contents of the 2nd dropdown box according to what the user will select on the 1st one. obviously the fields would come from the database. The 1st dropdown works fine, but when i select from it nothing happens on the other one.

I have 2 tables here:

ps_ref_region(table name)



ps_ref_province(table name)





<td>     <?php echo $form->labelEx($model,'Region'); ?></td>

           <td>		<?php 

              echo $form->dropDownList($model,'region_reference_id',CHtml::listData(Region::model()->findAll(),'region_reference_id','region_name'),


                            'ajax' => array(

                            'type' => 'POST',

                            'url' => CController::createUrl('Institution/address'),

                            'update' => 'province_reference_id'






          			<?php echo $form->error($model,'region_reference_id'); ?>





                <td>  <?php echo $form->labelEx($model,'Province'); ?></td>

                <td><?php echo $form->dropDownList($model,'province_reference_id',array());?></td>

				<?php echo $form->error($model,'province_reference_id'); ?>




public function actionAddress() {

            $region_id = $_POST['Institution']['region_reference_id'];


                    array(':region_reference_id'=> $region_id));


            foreach($data as $value=>$subcategory)  {

                echo CHtml::tag('option',




First I suggest you to use FireBug and see what is the server answer, maybe there is some error. Or you can run actionAddress() manually and see what happens. Usually it helps a lot :)

Actually I think I see the problem:

'update' => 'province_reference_id'

It must a valid css selector, e.g. ‘#province_reference_id’. But since you are using ActiveForm, it creates more complex ids, so do this:

'update' => '#'.CHtml::activeId($model, 'province_reference_id')

thank you very much! that did the job. im starting to love yii and its all thx to guys like you :) hope to be able to help other people too

hi @andy_s i would like to know how to manually run the actionAddress(), will i put that name in the address bar of the browser?

What do you mean by "manually"? You want to see a page or access it from javascript?

Think another way for that. I preferred jQuery post. If need any help plz feel free to send PM. Rajib Kumar Rakhmit