QUESTION 2
If someone selects the "First time buyer" checkbox (firstTimeBtn) the "firstBuyer" values should be returned, however, in addition to this, "firstBuyer" values should only be returned when the house price is £500,000 or under. If the house price is over £500,000 "standBuyer" values should be returned instead.
From Data Controller Module:
getBuyerType: function() {
const covidBtnCheck = document.getElementById(DOMstrings.covidBtn)
const firstTimeBtnCheck = document.getElementById(DOMstrings.firstTimeBtn)
const secondPropBtnCheck = document.getElementById(DOMstrings.secondPropBtn)
if (covidBtnCheck.checked && secondPropBtnCheck.checked) {
return 'secondCovidBuyer';
} else if (firstTimeBtnCheck.checked) {
return 'firstBuyer';
} else if (secondPropBtnCheck.checked) {
return 'secBuyer';
} else if (covidBtnCheck.checked) {
return 'covidBuyer';
} else {
return 'standBuyer';
}
},
}
AND
let checkBuyerType = function() {
let buyerType = UICtrl.getBuyerType();
if (buyerType == 'secondCovidBuyer') {
return dataCtrl.secondCovidBuyer;
} else if (buyerType == 'firstBuyer') {
return dataCtrl.firstBuyer;
} else if (buyerType == 'secBuyer') {
return dataCtrl.secBuyer;
} else if (buyerType == 'covidBuyer') {
return dataCtrl.covidBuyer;
} else {
return dataCtrl.standBuyer;
}
}
Originally, I tried adding "&& (houseCost <= 500000)" into the getBuyerType script within the "else if (firstTimeBtnCheck.checked) { return 'firstBuyer';" line, but it doesn't work. Wondering if it's because I should be using housePrice instead of houseCost? Including the below code for context, in case it is helpful:
//1. Get the cost of the house
houseCost = UICtrl.getInput().housePrice;
//2. Only proceed if there is a house cost
if (houseCost >= 0) {
QUESTION 1 (SOLVED)
I have 3 checkboxes and each checkbox returns different numerical values in a table. However, I want to add another option so that if both 'covidBtn' AND 'secondPropBtn' are selected, it will return 'secondCovidBuyer' values. I would really appreciate it if anyone is able to help me! Thank you.
Return Values
// Different tax percentages and taxBand data
standBuyer: [0, 0.02, 0.05, 0.05, 0.05, 0.10, 0.12],
firstBuyer: [0, 0, 0, 0.05],
secBuyer: [0.03, 0.05, 0.08, 0.08, 0.08, 0.13, 0.15],
covidBuyer: [0, 0, 0, 0, 0.05, 0.10, 0.12],
secondCovidBuyer: [0.03, 0.03, 0.03, 0.03, 0.08, 0.13, 0.15],
taxBand: [0, 125000, 250000, 300000, 500000, 925000, 1500000, Infinity],
Function
getBuyerType: function() {
if (document.getElementById(DOMstrings.firstTimeBtn).checked == true) {
return 'firstBuyer';
} else if (document.getElementById(DOMstrings.secondPropBtn).checked == true) {
return 'secBuyer';
} else if (document.getElementById(DOMstrings.covidBtn).checked == true) {
return 'covidBuyer';
} else {
return 'standBuyer';
}
},
Aucun commentaire:
Enregistrer un commentaire