2

I've been stalking here for longer than I can remember, this is my first post so I hope i get this right. I want to be able to have a Minimum and Maximum Price Dropdowns, and when someone selects a minimum price it is to auto-update the Maximum Price with the minimum value selected. here's my code so far... (taken from a previous post by someone else but I can get it to work properly. It is working in theory, but if i select say £90,000.00 it remove everything that contains a number less than a 9.

I guess I need to know how to get the Javascript to treat it as a number/numeric so it knows that 110000 is higher than 90000

$(window).load(function(){
var maxprice = $('#maxprice').html();
$('#minprice').change(function() {
$('#maxprice').html(maxprice);
$('#maxprice option').each(function() {
    if ($(this).val() <= $('#minprice').val()) $(this).remove();
});
});
});

<div><select name="minprice" class="searchboxes" id="minprice">
<option value="0">No Minimum</option>
<?php for ($n = 10000; $n <= 250000; $n += 10000) { ?>
<option value="<?php echo $n; ?>"><?php echo number_format($n, 2, '.', ','); ?>        </option><?php  } ?>
<?php for ($n = 275000; $n <= 500000; $n += 25000) { ?>
<option value="<?php echo $n; ?>"><?php echo number_format($n, 2, '.', ','); ?>    </option><?php  } ?>
<?php for ($n = 550000; $n <= 1000000; $n += 50000) { ?>
<option value="<?php echo $n; ?>"><?php echo number_format($n, 2, '.', ','); ?>    </option><?php  } ?>
<?php for ($n = 1100000; $n <= 2500000; $n += 100000) { ?>
<option value="<?php echo $n; ?>"><?php echo number_format($n, 2, '.', ','); ?>    </option><?php  } ?>
<?php for ($n = 3000000; $n <= 5000000; $n += 250000) { ?>
<option value="<?php echo $n; ?>"><?php echo number_format($n, 2, '.', ','); ?>    </option><?php  } ?>
<?php for ($n = 5000000; $n <= 15000000; $n += 500000) { ?>
<option value="<?php echo $n; ?>"><?php echo number_format($n, 2, '.', ','); ?>    </option><?php  } ?></select></div>

<div><select name="maxprice" class="searchboxes" id="maxprice">
<option value="0">No Maximum</option>
<?php for ($n = 10000; $n <= 250000; $n += 10000) { ?>
<option value="<?php echo $n; ?>"><?php echo number_format($n, 2, '.', ','); ?>    </option><?php  } ?>
<?php for ($n = 275000; $n <= 500000; $n += 25000) { ?>
<option value="<?php echo $n; ?>"><?php echo number_format($n, 2, '.', ','); ?>    </option><?php  } ?>
<?php for ($n = 550000; $n <= 1000000; $n += 50000) { ?>
<option value="<?php echo $n; ?>"><?php echo number_format($n, 2, '.', ','); ?>    </option><?php  } ?>
<?php for ($n = 1100000; $n <= 2500000; $n += 100000) { ?>
<option value="<?php echo $n; ?>"><?php echo number_format($n, 2, '.', ','); ?>    </option><?php  } ?>
<?php for ($n = 3000000; $n <= 5000000; $n += 250000) { ?>
<option value="<?php echo $n; ?>"><?php echo number_format($n, 2, '.', ','); ?>    </option><?php  } ?>
<?php for ($n = 5000000; $n <= 15000000; $n += 500000) { ?>
<option value="<?php echo $n; ?>"><?php echo number_format($n, 2, '.', ','); ?>    </option><?php  } ?>
</select></div>

Thank you in advance.

1 Answer 1

2

Try parseInt

if (parseInt($(this).val()) <= parseInt($('#minprice').val())) $(this).remove();

1
  • Wow! Wow! Wow! Thank you so much. that seems to have worked a treat! Thank you so much for taking the time to help me. I think I may have found my favourite forum! thank you so much.
    – Razza
    Nov 20, 2012 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.