I'm programatically generating select's with integer options (from 0 to 18) My aim is to filter the results into separate categories of ages like : infant less than 2 children greater than 2 less than 18 Adult greater or equal to 18
$('.passengerAge').filter(function (req1) {
var valbebe = parseInt($(this).val(), 10) <= 2;
return valbebe;
});
$('.passengerAge').filter(function (req2) {
var valadulte = parseInt($(this).val(), 10) >= 18;
return valadulte;
});
$('.passengerAge').filter(function (req3) {
var valenfant = parseInt($(this).val(), 10) < 18 && parseInt($(this).val(), 10) > 2 ;
return valenfant;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select class="passengerAge" id="select_1" name="select_1">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
</select>
The code is working, but only displaying the last returned value. second, i need to display every returned value in hidden and separated text inputs, so i have first to get the values and then push them into inputs.
Any hints ?