Skip to content Skip to sidebar Skip to footer

Dropdown Javascript Onload

I have a dropdown menu, that has a onchange function. Once the function is executed it changes another dropdown menu. I need to make it so it executes the script onload. 1st dropdo

Solution 1:

Move the onchange code into its own function (it should be there anyway), and execute that function in the ready() function.

That way it will fire both onchange and onload.

Solution 2:

I do the same check my code it may help you .But i use ajax and jquery.

For firs dropdown .

echo$form->dropDownListGroup(
                    $model'id', array(
                'wrapperHtmlOptions' => array(),
                'widgetOptions' => array(
                    'data' => abc::getName($model->id),
                    'htmlOptions' => array(
                        'prompt' => 'Select Project',
                        'ajax' => array(
                                'type' => 'POST',
                                'url' =>  ( Yii::app()->createUrl('/' . $domain_name . '/qq/xyz/abc') ),
                                'update' => '#seconddropdownid',
                                //'dataType' => 'json','data'=>array('id'=>'js:this.value'),

                              )
                            ),
                        ),
              )
            );

in second dropdown :

echo$form->dropDownListGroup(
                $project, 'tag', array(
            'wrapperHtmlOptions' => array(),
            'widgetOptions' => array(
                'data' =>$this->getProjectTags(),
                'htmlOptions' => array(
                    'prompt' => 'Select Tags',
                ),
            )
                )
        );

on change of the second list you can update the the list-view of yii .

Post a Comment for "Dropdown Javascript Onload"