Activedropdown On Change Event

this is my view:

<?php

&#036;em=EmployerJobs::model()-&gt;findAll();


&#036;model = new EmployerJobs();


&#036;list = CHtml::listData(&#036;em,'Employer_JobsJobCode','Employer_JobsJobCode');


echo CHtml::activeDropDownList(&#036;model,'Employer_JobsJobCode',&#036;list, array('empty' =&gt; 'Please Select'));

?>

it’s working fine, select making a list of values from table called employerjobs,

now i need to create onchange event for dropdown, if i change value in dropdown it should retrive particular row details.

im newbie on yii, i confused, i seeking for help. TIA

[color="#006400"] /* moved from Miscellaneous */[/color]

[quote=“kiranjv”]

this is my view:

<?php

&#036;fa=EmployerJobs::model()-&gt;findAll();


&#036;model = new EmployerJobs();


&#036;list = CHtml::listData(&#036;fa,'Employer_JobsJobCode','Employer_JobsJobCode');


echo CHtml::activeDropDownList(&#036;model,'Employer_JobsJobCode',&#036;list, array('empty' =&gt; 'Please Select'


, 'id'=&gt; 'shrtlst_candt_jobcode', 


'ajax' =&gt; array(


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


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


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


'update'=&gt;'#shrtlst_candt-firstname2', //selector to update


'data'=&gt;&quot;javascript:&#036;('#shrtlst_candt_jobcode option:selected').val();&quot;


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

)));

?&gt;

it’s working fine, select making a list of values from table called employerjobs,

This is my controller

    public function actionShortlistCan()


{


	&#036;model = new Candidateinterview;


	 &#036;new_interviews = Candidateinterview::model()-&gt;findAllByAttributes(array('AspirantID'=&gt;&#036;model-&gt;AspirantID,'ConfirmInterview'=&gt;0));


	 &#036;model = new EmployerJobs;


		&#036;data = EmployerJobs::model()-&gt;findAll();


				/*'Employer_JobsJobCode', 


              array(&#036;_POST['Employer_JobsJobCode'])*/





		&#036;data=CHtml::listData(&#036;data,'Employer_JobsJobPos','Employer_JobsJobLoc');


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


	 {


 		   echo CHtml::tag('h3',


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


		}


}

if i change value in dropdown it should retrive particular row details.

im newbie on yii, i confused, seeking for any help. TIA

Just have a look at this wikki article

i hope you can get idea where are you doing mistake.

have you seen that function from above given link and compared your function in controller.




public function actionDynamiccities()

{

    $data=Location::model()->findAll('parent_id=:parent_id', 

                  array(':parent_id'=>(int) $_POST['country_id']));

 

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

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

    {

        echo CHtml::tag('option',

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

    }

}



just have look into this code and compare it with your once.i hope you will get some difference.

Thanks for your comment…

i got the difference