function createPriceOptions(pricearray, lastdefault) {
    var r = "";
    var sel_ix = 0;
    if (lastdefault) sel_ix = pricearray.length - 1;
    for (var i = 0; i < pricearray.length; i++) {
        r = r + "<option value=\"" + pricearray[i][0] + "\"";
        if (i == sel_ix) r = r + "selected";
        r = r + ">" + pricearray[i][1] + "</option>";
    }
    return r;
}

function savePriceRangeOptions(buy, rent) {
    $("#Tenure").change(function() {
        var pricearray = ($(this).val() != "3") ? buy : rent;
        $("#nPrice").html(createPriceOptions(pricearray, false));
        $("#xPrice").html(createPriceOptions(pricearray, true));
    });
}
    
    
