menu
function testSelect(form) {
//get year they moved;
yearraw = form.years.selectedIndex;
//get current monthly rent;
rentraw = form.inputbox.value;
//annual average overpaid rent 2012 to 2020;
var rents = [125, 922, 523, 1446, 1916, 2486, 2902, 2032, 3110];
//cumulative overpaid rent in millions by 2020- starting from 2012;
var totals = [869, 863, 818, 792, 717, 614, 476, 309, 188];
//average rent in 2020 if only followed wage inflation;
inflationrent = 916;
//weight actual rent vs average rent;
weight = rentraw / 1175;
//sum the yearly overpay using year they moved;
var sliceyears = rents.slice(yearraw,);
var sumyears = sliceyears.reduce(function (a, b) {
return a + b;
}, 0);
//apply weight to overpay;
overpay = sumyears * weight;
overpayd = Number(overpay);
//rent if only inflated x weight;
currentinflatedrent = inflationrent * weight;
var outputboxa = document.querySelector(‘span.outputboxa’);
var outputboxb = document.querySelector(‘span.outputboxb’);
var outputboxc = document.querySelector(‘span.outputboxc’);
var outputboxd = document.querySelector(‘span.outputboxd’);
var outputboxe = document.querySelector(‘span.outputboxe’);
outputboxa.innerText = Math.round(currentinflatedrent).toLocaleString(“en-GB”);
outputboxb.innerText = Math.round(overpayd).toLocaleString(“en-GB”);
//display stuff;
outputboxc.innerText = totals[yearraw];
yearnum = 8 – yearraw;
outputboxd.innerText = yearnum;
outputboxe.innerText = 2012 + yearraw;
}