0
任何人都可以幫助我如何正確使用tofixed
功能在我的腳本,因爲我有點新的瞭解,當我把我的腳本tofixed不會工作...請幫助我。關於在tofixed函數在javascript
當前腳本:
<script>
function optTotal1()
{
var a1 = document.querySelector('select[name="optA1"]');
var b1 = document.querySelector('select[name="optB1"]');
var c1 = document.querySelector('select[name="optC1"]');
var d1 = document.querySelector('select[name="optD1"]');
var e1 = document.querySelector('select[name="optE1"]');
if (a1.value && a1.value != "")
a1 = parseFloat(a1.value);
else
a1 = 0;
if (b1.value && b1.value != "")
b1 = parseFloat(b1.value);
else
b1 = 0;
if (c1.value && c1.value != "")
c1 = parseFloat(c1.value);
else
c1 = 0;
if (d1.value && d1.value != "")
d1 = parseFloat(d1.value);
else
d1 = 0;
if (e1.value && e1.value != "")
e1 = parseFloat(e1.value);
else
e1 = 0;
document.getElementById("total1").value.toFixed(2) = parseFloat(a1)+parseFloat(b1)+parseFloat(c1)+parseFloat(d1)+parseFloat(e1);
}
</script>