Problem With Dependent Dropdown List

I have controllers Students,Programs and Courses. in my courses view _Form i have this code

<div class="row">

		<?php echo $form->labelEx($model,'pname'); ?>



<?php echo $form->dropDownList($model,'pname',CHtml::listData(Programs::model()->findAll(

  array('order' => 'pname')),'pname', 'pname'),



    'prompt'=>'Choose you university',



      'url' => CController::createUrl('students/findcourses'),

      'data'=> array('pname'=>'js:this.value'),




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



	<div class="row">

		<?php echo $form->labelEx($model,'cname'); ?>

		<?php echo CHtml::dropDownList('cname','', array(),

               array('prompt'=>'Choose course','class'=>'form-control')); ?>


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


i have findcourses method in Student controller here is code

public function actionFindcourses()


        $data = Courses::model()->findAll('pname=:pname',




        echo "<option value=''>Courses</option>";

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

            echo CHtml::tag('option', array('value'=>$value),CHtml::encode($name),true);


pls help

I think u have followed this wiki page

But u have not mentioned what is your exact problem :(

you mentioned i have problem… what is problem? what output did u get during this code exection? have u tried anyother code?

First drop down appears well but when i select Programs ,Courses drop down shows nothing


what output are you getting from the findcourses ? can you see the option tag with constructed value ? please chekc the response in console

Check the link below, you might find something useful with an explanation on AJAX dropdown lists.


Maybe you want use:

find course shows only blank dropdown

Hi pradip,

you have not answered my question.

did u check your response via [size=2]browser [/size][size=2] console [/size][size=2]for your request[/size][size=2].[/size]



[size=2]when your controller returned something then only it get displayed in VIEW. so please confirm your controller method.[/size]



[size=2]you should try to identify where is the problem… in MODEL or VIEW or CONTROLLER :([/size]