I am building a calculator that gives the state specific sales tax of a real estate transaction. I know my "normalrtfCalc" function works but my issue is getting the "amount" from the form into the function and the result into the output. Any help would be greatly appreciated. Thanks!
Here is my HTML:
<form id="rtfCalc" oninput="updateOutput( )">
<input name="sale amount" type="number" value="0" />
<output name="transfer fee" for="sale amount"></output>
</form>
Here is my JS:
function updateOutput() {
var form = document.getElementById("rtfCalc");
var out = form.elements["transfer fee"];
var amount = parseInt(form.elements["sale amount"].value);
function normalrtfCalc(amount) {
if (amount <= 150000) {
out.value = Math.ceil(amount / 500) * 2;
} else if (amount <= 350000) {
if ((amount - 150000) <= 50000) {
out.value = 600 + (Math.ceil((amount - 150000) / 500) * 3.35);
} else {
out.value = 935 + (Math.ceil((amount - 200000) / 500) * 3.9);
}
} else {
if ((amount - 200000) <= 350000) {
out.value = 2735 + (Math.ceil((amount - 200000) / 500) * 4.8);
} else if ((amount - 550000) <= 300000) {
out.value = 4655 + (Math.ceil((amount - 555000) / 500) * 5.3);
} else if ((amount - 850000) <= 150000) {
out.value = 7835 + (Math.ceil((amount - 850000) / 500) * 5.8);
} else {
out.value = 9575 + (Math.ceil((amount - 1000000) / 500) * 6.05);
}
}
}
};
form,outandamountaren't working? Can you tryconsole.log(var)for each of them?