Hi, i would like to ask something, i have a table like this :
The user will enter a value in the column "out Quantity", then, i want it auto calculate in "Total Price" which is
Total Price = Old balance quantity * out quantity and
new Balance = old balance quantity - out Quantity
how can i do that?
I tried to do it like this, but it won't work :
<script>
function compute() {
var price = document.getElementById('valuePerUnit');
var outqty = document.getElementById('k9goodsQty');
var total = document.getElementById('valueTotal');
var oldqty = document.getElementById('goodsQty');
var balance = document.getElementById('qtyBalance');
var v1=value.value;
var v2=outqty.value;
var v3=total.value;
var v4=oldqty.value;
var v5=balance.value
var val1 = v1==="" ? 0 : parseFloat(v1);
var val2 = v2==="" ? 0 : parseFloat(v2);
var val3 = v3==="" ? 0 : parseFloat(v3);
var val4 = v4==="" ? 0 : parseFloat(v4);
var val5 = v5==="" ? 0 : parseFloat(v5);
jumlah.value = val1 * val2;
baki.value = val4 - val2;
}
</script>