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' => 'alert("selected value : " + 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 to populate the select. Must be an array.
'data' =>Yii::app()->params['cost_max_resales'],
// options passed to plugin
'options' => array(
'onSelect' => 'alert("selected value : " + item.value);',
'allowText' => false,
),
// Options passed to the text input
'htmlOptions' => array('placeholder' => 'Max Cost', 'style'=>'width:70px'),
));
//echo $form->dropDownList($model,'city', Yii::app()->params['city'], array('style'=>'width:120px'));
?>
Now, I want to make the second dropdownlist to have 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.
For this I’m using the below script:
<script>
$('#SearchForm_min_cost').on('change', function(e){
var $options = $(this).find('option');
$('#SearchForm_max_cost_select').html('');
$.each($options, function(i, element){
if($(element).attr('value')>$('#SearchForm_min_cost').val()){
$('#SearchForm_max_cost_select').append($(element).clone());
}
})
})
</script>
But, this script isn’t working either. How can I pass values to this to make it work.