HTML フォームで記述している次の JavaScript コードがあります。
<script type="text/javascript">
function updatesum() {
document.functie.column8.value = (document.functie.column6.value -0) * (document.functie.column7.value -0);
document.functie.column12.value = (document.functie.column10.value -0) * (document.functie.column11.value -0);
document.functie.column16.value = (document.functie.column14.value -0) * (document.functie.column15.value -0);
document.functie.column20.value = (document.functie.column18.value -0) * (document.functie.column19.value -0);
}
次のようなphpフォームを使用します。
echo "<td><input name=\"column6\" onChange=\"updatesum()\"></td>";
echo "<td><input name=\"column7\" onChange=\"updatesum()\"></td>";
問題は、最初の形式にいくつかの値を入力すると合計が得られることですが、いくつかの値を入力しないとゼロになり、これは望ましくありません。
http://img17.imageshack.us/img17/5456/hyhu.png http://img17.imageshack.us/img17/5456/hyhu.png
一番下には、3 番目の列のすべての値の合計がありますが、2400 または 2300.44 のような数値が得られ、2,400 を出力するか、2300.44 を 2,300 に切り上げたいと考えています。どうやってやるの?