function javascript ini disimpennya di head
function hitungColumn(){
c=3 // menentukan jumlah element "total" agar hasilnya dinamis dapatkan jumlah dari hasil query menggunakan php
d=document; // biar gak panjang aja... di ilangin juga bisa...

xxx=0;
for(i=1;i<=c;i++){
xxx=eval(parseInt(xxx)+parseInt(d.getElementById("total"+i+"").value));
// kalo di ilangin tu yang d=document...
// nulisnya jadi gini xxx=eval(parseInt(xxx)+parseInt(document.getElementById("total"+i+"").value));
}
d.getElementById("grandTotal").value=xxx;
}


function test(objHarga,objJumlah,objTotal){

if(objJumlah.value==""){
objJumlah.value=0;


}else if(objJumlah.value==""){
objJumlah.value=0;


}
objTotal.value=parseInt(objHarga.value)*parseInt(objJumlah.value);
hitungColumn();
//alert(objTotal.value);
}



code yang ini disimpennya di body


<form action="" method="post">

<table width="50%" border="1">

<tr>

<td width="28%"><div align="center">Nama Produk</div></td>

<td width="42%"><div align="center">Harga</div></td>

<td width="19%"><div align="center">Jumlah</div></td>

<td width="11%"><div align="center">Total</div></td>

</tr>

<tr>

<td>N70</td>

<td>

<label>

<input type="text" name="harga1" id="harga1" value="1500000" onkeyup="test(this,document.getElementById('jumlah1'),document.getElementById('total1'));"/>

</label></td>

<td><label>

<input type="text" name="jumlah1" id="jumlah1" value="0" onkeyup="test(document.getElementById('harga1'),this,document.getElementById('total1'));"/>

</label></td>

<td><label>

<input type="text" name="total1" id="total1" value="0" onkeyup="hitungColumn();" readonly=""/>

</label></td>

</tr>

<tr>

<td>N73</td>

<td><label>

<input type="text" name="harga2" id="harga2" value="2000000" onkeyup="test(this,document.getElementById('jumlah2'),document.getElementById('total2'));"/>

</label></td>

<td><label>

<input type="text" name="jumlah2" id="jumlah2" value="0" onkeyup="test(document.getElementById('harga2'),this,document.getElementById('total2'));"/>

</label></td>

<td><label>

<input type="text" name="total2" id="total2" value="0" readonly=""/>

</label></td>

</tr>

<tr>

<td>N95</td>

<td><label>

<input type="text" name="harga3" id="harga3" value="5000000" onkeyup="test(this,document.getElementById('jumlah3'),document.getElementById('total3'));"/>

</label></td>

<td><label>

<input type="text" name="jumlah3" id="jumlah3" value="0" onkeyup="test(document.getElementById('harga3'),this,document.getElementById('total3'));"/>

</label></td>

<td><label>

<input type="text" name="total3" id="total3" value="0" readonly=""/>

</label></td>

</tr>

<tr>

<td colspan="3"><div align="right">Grant Total</div></td>

<td><label>

<input type="text" name="grandTotal" id="grandTotal" value="0" readonly=""/>

</label></td>

</tr>

</table>

</form>