在下面的函数中,我将在哪里包含 num.toFixed(2); 使“总计”的估价器显示到小数点后 2 位(价格)?
function calculate_total(id) {
var theForm = document.getElementById( id )
total = 0;
if (theForm.toyCar.checked) {
total += parseFloat(theForm.toyCar.value);
}
theForm.total.value = total;
theForm.GrandTotal.value = total + (total*0.18);
}
这是输出:
<input type="button" name="CheckValue" value = "Calculate cost" onclick="calculate_total(this.form.id)" />
Total: <input type="text" name="total" id="total" size="10" readonly="readonly" />