Ok so i have a txt file containing values from 40 to 400 like this: 40 50 60...etc. I have two '' in my html and i want the values of second to be greater than selected from first.
<div class="col-md-3">
<div class="form-group">
<label for="value_from">From</label>
<select class="form-control" id="value_from" name="value_from">
<?php
$txt = file('includes/file.txt');
echo '<option>--</option>';
foreach ($txt as $line) {
echo '<option value="'.$line.'">'.$line.'</option>';
}
?>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="value_to">To</label>
<select class="form-control" id="value_to" name="value_to">
<?php
$txt = file('includes/file.txt');
echo '<option>--</option>';
foreach ($txt as $line) {
echo '<option value="'.$line.'">'.$line.'</option>';
}
?>
</select>
</div>
</div>
ajax to handle it looks like this
$(document).on('change', '#values_from', function() {
$('#galia_iki').html('');
$.ajax({
url: 'includes/file.txt',
type: 'get',
dataType: 'text',
data: {param1: 'value1'},
success: function(data){
$('#values_to').html('');
$('#values_to').append('<option>--</option>')
var array = data.split('
');
var from = $('#values_from').children(':selected').attr('value');
console.log(nuo);
$(array).each(function(index, el) {
if (el>from) {
console.log(el);
$('#values_to').append('<option value="'+el+'">'+el+'</option>')
}
});
}
});
});
but what happens when i check if(el>from)
it doesn't return proper values. E.g if I choose 40 from first list I get weird values:
40 50 60 70 80 90 400
so what happens to values inbetween? Am I missing something in my code? By the way, I have two more groups like this with same code but different values and it runs fine. Also, if i select 90 it doesn't return any values. If anything over 100 it returns all the values, even less than selected.