I’m new to Yii framework and Javascript. Now, I’m using two dropdownlists for min_cost and max_cost. I’m using the below code to list the values in the dropdownlist.
<?php
$this->widget('ext.combobox.EJuiComboBox', array(
'model' => $model,
'attribute' => 'min_cost',
'data' => Yii::app()->params['cost_min_resales'],
'options' => array(
'onSelect' => 'cost_change(item.value);',
'allowText' => false,
),
'htmlOptions' => array('placeholder' => 'Min Cost', 'style'=>'width:70px'),
));
?>
<?php
$this->widget('ext.combobox.EJuiComboBox', array(
'model' => $model,
'attribute' => 'max_cost',
'data' =>Yii::app()->params['cost_max_resales'],
'options' => array(
'allowText' => false,
),
'htmlOptions' => array('placeholder' => 'Max Cost', 'style'=>'width:70px'),
));
?>
For this I’m using the below script:
<script>
function cost_change(price) {
var removed;
console.log("removed",removed);
select = "#SearchForm_max_cost_select";
var value = price;
console.log("value",value);
jQuery('#SearchForm_max_cost_select').prepend(removed);
var toKeep = jQuery('#SearchForm_max_cost_select option').filter( function( ) {
return parseInt(this.value) > parseInt( value);
} );
console.log("to keep",toKeep);
removed = jQuery('#SearchForm_max_cost_select option').filter( function( ) {
return parseInt(this.value) < parseInt( value);
} );
}
</script>
Now, I want to populate the second dropdownlist with values greater than the value selected in first one. Suppose there are values hardcoded in an array as (1,2,3,4,5) I select 2 from first dropdownlist then all values greater than 2 (i.e 3,4,5) should be listed in second dropdownlist.
The above script works fine. I can see the values of second dropdownlist printed in the logs . But, I’m not able to pass this values to second dropdownlist. How can I do this.