Redirect to a page depending on value selected in dropdown?

hI all,

Can anybody tell me how to Redirect to a page depending on value selected in dropdown? I dont want to use dropdownredirect widget. Is there any other way of doing this?


You should do it in javascript. At the onchange of the ddl you can redirect with js.

Hi zaccaria,

thanks for the prompt reply

Can you please show me anexample of how to use js in it?


$form->dropDownList($model, attribute, array(), array('onChange'=>'window.location='))

Instead of google you should redirect on a url, that you will generate in javascript using something like:

$(this).find('option: selected').val();

take a look at jquery documentation for retriving the value from the ddl.

OK will try that.

Thanks a lot.

redirecting the page worked but now i want to pass the selected value from the ddl to a controller.

How to do that?

You should compose the url with js.

For example:


url= "'.CHtml::normalizeUrl().'";

url= url+"&id="+$(this).find('option: selected').val();


I am currently sending a static value through the url like so

<? echo CHtml::DropDownList($model,'job_card',$data1,array(


			'onchange' =>'window.location='.Yii::app()->baseUrl.'/index.php/JobCards/jobcardrequirement?job_card=62 ',






But i want to send the value for job_card dynamically. How do i do this?

Please advice.


Better To use partially Render in that U cant Use Any View which want to load

better than Redirect page

and that should be in controller of that page