I have two dropdowns
- Age(from)
- Age(to)
when I select the age from value from first dropdown list I want only the ages greater than that age to be displayed in the second dropdown list. So I want to remove all ages less than or equal to the first value that I selected from the first one.
$('#age_from').change(function(){
var val = $(this).children('option:selected').val();
$('#age_to').children().each(function(){
if($(this).val() <= val){
$(this).remove();
}
});
});
Here using each function I'm able to iterate through all the values in the select(id = age_to) but somehow not able to remove the options.
<div class="height_item"style="margin-left: 10px;">
<h4 style="margin-right: 19px !important;">From (age)</h4>
<select class="selectpicker" name="age_from" id="age_from">
<option>20</option>
<option>30</option>
<option>40</option>
</select>
</div><br><br>
<div class="height_item">
<h4 style="margin-right: 41px !important;">To (age)</h4>
<select class="selectpicker" name="age_to" id="age_to">
<option>25</option>
<option>35</option>
<option>55</option>
</select>
</div>
Any help will be appreciable. Thank you