以下の関数では、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" />