0

I'm new to Yii framework. I have two dropdownlists with their values hardcoded in properties file. The dropdownlists are created using the below code:

<?php
$this->widget('ext.combobox.EJuiComboBox', array(
    'model' => $model,
    'attribute' => 'min',
    'data' => Yii::app()->params['min_values'],
    'options' => array(
        'allowText' => false,
     ),
     'htmlOptions' => array('placeholder' => 'Min', 'style'=>'width:70px'),
));
?> 

So now I want to get the hardcoded values in second dropdownlist based on first.

If first dropdownlist has hardcoded values[1,2,3,4] and second dropdownlist has hardcoded values [1,2,3,4]. Suppose I select 2 in first dropdownlist, the second dropdownlist should have values 3 and 4(greater than value selected in first). How can I do this?

4

1 回答 1

0

这个问题与 yii 无关。你应该使用 javascript 来做类似的事情。

开始检查:

<select id='first'>
    <option value='1'>1</option>
    <option value='2'>2</option>
    <option value='3'>3</option>
    <option value='4'>4</option>
</select>

<select id='second'>
</select>

<script>
$('#first').on('change', function(e){
    var $options =  $(this).find('option');
    $('#second').html('');
    $.each($options, function(i, element){
        if($(element).attr('value')>$('#first').val()){
            $('#second').append($(element).clone());
        }
    })
})
</script>

http://jsfiddle.net/kj5TK/

于 2013-11-08T08:04:53.613 回答