I am a designer first and foremost, html and css make sense to me. JS has been a whole new nightmare. I love it but I am going the self-taught route. My workplace knows I am pretty good at figuring computer things out so I was asked to put together a calculator for our prepay forms.
I am trying to take the total found in the first half and then figure out the sales tax based off of the subtotal and the tax rates for specific counties. We have about 5 counties that we serve. Currently I have the subtotal being figured out using a checkbox section so they can choose multiple services. And then for tax I have a drop down menu.
Any help would be appreciated. I feel like I have been smashing my head against the wall for the last two weeks trying to learn as much as I can.
document.body.innerHTML ; //refreshes page
const recalculateText = document.querySelector(".recalculate-text");
const checkboxContainer = document.querySelector("#checkbox-container");
let total = 0;
const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
});
checkboxContainer.addEventListener('change'); e => {
if (e.target.tagName == "INPUT") {
const floatValue = parseFloat(e.target.value);
if (e.target.checked) {
total += floatValue;
} else {
total -= floatValue;
}
}
recalculateText.innerHTML = formatter.format(total);
});
var county = document.getElementById("dropDown"); //the element getting got is the dropDown list
var subtotal = document.getElementById("recalculateText");
var dropDown = county;
function taxCalculation() { //declaring function as taxCalculation
const "county1" = 0.738;
const "county2" = 0.7875;
const "county3" = 0;
const "county4" = 0.738;
const "county5" = 0.738;
dropDown.addEventListener("change"); event => ;{ //declaring what change is paying attention to
// trying to get subtotal of calculatetext * (1 + county / 100)
if (event.target.tagName == "option") {
const floatValue = parseFloat(event.target.value);
if (event.target.select) {
"subtotal" * (1 + "county" / 100);
} else {
"0";
}
}
});
}