I can't get the var total to resolve by using addition. It will work with multiplication operator: var total = subtotal * sales_tax but not with the + sign addition operator: var total = subtotal + sales_tax. Any help would be most appreciated.
var calculate_click = function () {
var subtotal = parseFloat(document.getElementById("subtotal").value).toFixed(3);
var taxRate = parseFloat(document.getElementById("tax_rate").value).toFixed(3);
if (isNaN(subtotal) || isNaN(taxRate)) {
}
else {
var sales_tax = (subtotal * taxRate / 100);
parseFloat(document.getElementById("sales_tax").value = sales_tax.toFixed(3));
var total = subtotal + sales_tax;
parseFloat(document.getElementById("total").value = total.toFixed(3));
}
}
parseFloat()around the code where you set the field values are pointless.parseFloat?