HOW to Use onChange on DropDownList

Hi, I cannot resolve this.

I have an Action that render a view with a Combo and a Grid.

The grid should be populated when the user pick something from the combo.

I sure I have to use “onChange” event, but I don’t figure ir out.

this is my widget:

		<?php echo $form->dropDownList($model->model, 'fk_alumno_id', 

			GxHtml::listDataEx(Alumno::model()->findAllAttributes(null, true, $crit)), 


				'onChange' => 'submit',

				'prompt' => Yii::t('app', 'Seleccione un Alumno'),


				)); ?>

What I whant is that when the combo fires onChange, the form should be re submited with a id of the combo as paremeter, in this case: fk_alumno_id

Any sugestions ??

Best Regards

I use this:

I then handle the parameter in my controller.

You could also use a simple form, like this:

<?php echo CHtml::form('issues','get', array('class' => 'floatrightup')); ?>

<?php echo CHtml::dropDownList('issueFilter',



    array('empty'=>'All Issues', 'submit'=>'')); ?>

<?php echo CHtml::endForm(); ?>

I have both the form and the dropdownredirect active on the same page, though you only need one for your use case.

ok, I’m having progess with your suggest. I see this jS function in the page:

$('body').on('change','#Alumno_id',function(){jQuery.yii.submitForm(this,'',{});return false;});

What I need is to pass the selected value as a parameter to the submit …

we are close ?


PS, I’m not using the redirect extension … yet

I don’t do anything besides the form in the view.

The rest is handled in the model by its search function:

   	if (isset($_GET['issueFilter'])) {

            if((int)$_GET['issueFilter']===1) {

                $criteria->compare('t.closed', 0, true);


            elseif((int)$_GET['issueFilter']===2) {

                $criteria->compare('t.closed', 1, true);


        } else {

            $criteria->compare('t.closed', 0, true);


Well, in the actionIndex:

    public function actionIndex($identifier = '') {

        $issueFilter = array('1' => 'Open Issues', '2' => 'Closed Issues');

        $model = new Issue('search');

        $model->unsetAttributes();  // clear any default values

That’s it.

well, this is enough for your case,

but what happends when the combo is filled with 100 records from the database !

I guess that I need to set some parameters in this function:

$(‘body’).on(‘change’,’#Alumno_id’,function(){jQuery.yii.submitForm(this,’’,{});return false;}

where : jQuery.yii.submitForm(this,’’,{}), the second parameter looks like the URL parameters.

So I need som function to retrieve the value of the selected option.

Best Regards