Skip to content

Instantly share code, notes, and snippets.

@jakab922
Created September 29, 2011 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakab922/1250566 to your computer and use it in GitHub Desktop.
Save jakab922/1250566 to your computer and use it in GitHub Desktop.
variable undefined
<script type="text/javascript" charset="utf-8">
var min_trans = '{% gettext searchboxes-form-min %}';
var max_trans = '{% gettext searchboxes-form-max %}';
var sale_type = 'R';
var sales_min_prices = [{% for num in sales_min_prices %}{{ num }}{% if not forloop.last %},{% endif %}{% endfor %}];
var sales_max_prices = [{% for num in sales_max_prices %}{{ num }}{% if not forloop.last %},{% endif %}{% endfor %}];
var rentals_min_prices = [{% for num in rentals_min_prices %}{{ num }}{% if not forloop.last %},{% endif %}{% endfor %}];
var rentals_max_prices = [{% for num in rentals_max_prices %}{{ num }}{% if not forloop.last %},{% endif %}{% endfor %}];
var min_bedrooms = [{% for num in min_bedrooms %}{{ num }}{% if not forloop.last %},{% endif %}{% endfor %}];
var max_bedrooms = [{% for num in max_bedrooms %}{{ num }}{% if not forloop.last %},{% endif %}{% endfor %}];
$('#min_price-select').change(function() {
var content = '<option value="9999999999">' + max_trans + '</option>';
var min_val = parseInt($("#min_price-select option:selected").attr("value"));
if(sale_type == 'R') {
for(var i = 0; i < rentals_max_prices.length; i++) {
if(rentals_max_prices[i] > min_val) {
if(i == rentals_max_prices.length - 1) {
content += '<option value="9999999999">' + rentals_max_prices[i] + '+</option>';
} else {
content += '<option value="' + rentals_max_prices[i] + '" >' rentals_max_prices[i] + '</option>';
}
}
}
} else {
for(var i = 0; i < sales_max_prices.length; i++) {
if(sales_max_prices[i] > min_val) {
if(i == rentals_max_prices.length - 1) {
content += '<option value="9999999999">' + sales_max_prices[i] + '+</option>';
} else {
content += '<option value="' + sales_max_prices[i] + '" >' sales_max_prices[i] + '</option>';
}
}
}
}
$('#max_price-select').text(content);
});
$('#max_price-select').change(function() {
var content = '<option value="0">' + min_trans + '</option>';
var max_val = parseInt($("#max_price-select option:selected").attr("value"));
if(sale_type == 'R') {
for(var i = 0; i < rentals_min_prices.length; i++) {
if(rentals_min_prices[i] < max_val) {
content += '<option value="' + rentals_min_prices[i] + '" >' rentals_min_prices[i] + '</option>';
}
}
} else {
for(var i = 0; i < sales_min_prices.length; i++) {
if(sales_min_prices[i] < max_val) {
content += '<option value="' + sales_min_prices[i] + '" >' sales_min_prices[i] + '</option>';
}
}
}
$('#min_price-select').text(content);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment