document.querySelector('#tax-form').onchange = function(){ var assessment = Number(document.getElementById('assessmentValue').value); var assessclass = document.getElementById('assessmentClass').value; var muniRate = 0; var schoolRate = 0; var seniorsRate = 0; var totalRate = 0; // referenceArray = [, ,,]; // var resRates = [5.2150, 2.3714, 0.1013, 7.6877], resRatesFlt = resRates.map(Number); // var nonresRates = [13.0211, 3.6711, 0.1013, 16.7935], nonresRatesFlt = nonresRates.map(Number); // var farmRates = [25.4555, 2.5682, 0.1024, 28.1261], farmRatesFlt = farmRates.map(Number); // var mandeRates = [7.7145, 0.0000, 0.1024, 7.8169],mandeRatesFlt = mandeRates.map(Number); var resRates2021 = [5.2549, 2.6220, 0.1047, 7.8334]; var nonresRates2021 = [13.8958, 4.1267, 0.1047, 18.0402]; var farmRates2021 = [37.4025, 2.6220, 0.1047, 39.9810]; var mandeRates2021 = [13.8958, 0.0000, 0.1047, 14.0005]; if (assessclass == 1) { muniRate = resRates2021[0]; schoolRate = resRates2021[1]; seniorsRate = resRates2021[2]; totalRate = resRates2021[3]; } else if (assessclass == 2) { muniRate = nonresRates2021[0]; schoolRate = nonresRates2021[1]; seniorsRate = nonresRates2021[2]; totalRate = nonresRates2021[3]; } else if (assessclass == 3) { muniRate = farmRates2021[0]; schoolRate = farmRates2021[1]; seniorsRate = farmRates2021[2]; totalRate = farmRates2021[3]; } else if (assessclass == 4) { muniRate = mandeRates2021[0]; schoolRate = mandeRates2021[1]; seniorsRate = mandeRates2021[2]; totalRate = mandeRates2021[3]; } var municipalValue = (muniRate / 1000) * assessment; var schoolValue = (schoolRate / 1000) * assessment; var seniorsValue = (seniorsRate / 1000) * assessment; var totalValue = (totalRate / 1000) * assessment; console.log(municipalAmount); console.log(schoolAmount); console.log(seniorsAmount); console.log(totalAmount); var municipalAmount = document.querySelector('#municipalAmount'); var schoolAmount = document.querySelector('#schoolAmount'); var seniorsAmount = document.querySelector('#seniorsAmount'); var totalAmount = document.querySelector('#totalAmount'); municipalAmount.value = municipalValue.toFixed(2); schoolAmount.value = schoolValue.toFixed(2); seniorsAmount.value = seniorsValue.toFixed(2); totalAmount.value = totalValue.toFixed(2); document.getElementById('results').style.display='block'; }