我无法通过使用添加来解决var total.它将与乘法运算符一起使用:var total = subtotal*sales_tax但不能使用+符号加法运算符:var total = subtotal + sales_tax.非常感激任何的帮助.
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));
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
313 次 |
| 最近记录: |