dropDownList onchange submit question?

I was just wondering if anyone knows a way to have a dropDownList auto submit and keep the url search engine friendly?

this is my code… it work but uses ?id=1 instead of /id/1

CHtml::dropDownList('id', $select, $list, array('onchange'=>'this.form.submit()'))

I changed my form to POST and used this method…

CHtml::dropDownList('id', $select, $list, array('submit'=>'controller/action'));

Which works fine and uses jquery… i’d still like to know a way to use GET and submit the form value via friendly url?

I’m using this

<?= CHtml::form(); ?>

        <?= CHtml::dropDownList('id', $select, $list, array('submit' => '')) ?>

<?= CHtml::endForm(); ?>

Yeah that’s what im doing and it works for $_POST method. Is there a way to use dropdown with $_GET and maintain friendly URL’s?

So onchange of dropDownList your url is /controller/action/id/1 instead of /controller/action/?id=1

how to onchange function in dropdownlist

Hi, i am new guy in Yii to, but i think somethings i can share with you:

If you want to give an onchange function in dropdownlist, you can following this code:






            'onchange' =&gt; 'alert(1)',



where $data is an array of listData

hope can help you :rolleyes:

If you are planning to use onchange and wishes to use $_GET you need to set up you ajax to use method get instead of post.

Have you setup urlManager in config file and in .htaccess to create friendly urls?

By the way, why you want to use SEO friendly URLs, on form submission pages, they will not be indexed by search engine anyway.

@Ivica note that you are posting on an old thread (last response from november 2010)… and in the Yii 1.0.x sub-forum (deprecated)…

Help me mdomba …

i want to post the form onchange, what to do?

Start a new topic in the Yii 1.1 forum, please. :)

got it myfriend,

<?php echo CHtml::dropDownList('id','select_value',$data,array('prompt'=>'Move To Folder','submit'=>array('user/inbox'))



<?php echo CHtml::dropDownList('id','select_value',$data,array('prompt'=>'Move To Folder','submit'=>'user/inbox')


*where data may CHtml::listData(…)

**user/inbox replace controller/action

Hi Rajith,

I am using a similar thing as u mentioned above. I want to pass some values to the action. How do i do this?

<?php echo CHtml::dropDownList('license_id', 'license', 



	              'empty'=>'Select License for this order',


	              'submit'=>array('order/addLicense', 'id'=>$model->orid), // id - will be sent as part of URL

	              'params'=>array('license_id'=>'js: $(this).val()'),      // license_id will be send via POST and its value is selected value of dropDown

	              'csrf'=>true,                                            // CSRF turned on in main config



Helpfull links: