jokecoat
Posts: 43
|
| Posted: 09/09/2008, 4:30 AM |
|
Hi. I need to calculate the sum of 18 values.
I would like to use javascript and onchange (client-side)
calculate field is s_total and values to sum are in h1..h18
Each field (h1...h18) should have the onchange.
Could anyone help me out? I took a look at order entry, but i can't figure out how it's done.
|
 |
 |
doxtor
Posts: 24
|
| Posted: 09/10/2008, 8:21 PM |
|
Is this what you mean?
function Show_Total()
{
var TotalSum=0;
var Summ;
for(var i = 0; i < store_orders_itemsElements.length; i++){
Summ = StrToFloat(store_orders_itemsElements[store_orders_itemspriceID].value) *
StrToFloat(store_orders_itemsElements[store_orders_itemsquantityID].value);
TotalSum = TotalSum + Summ;
if (Summ == 0) {
store_orders_itemsElements[store_orders_itemsSumPriceID].value = "";
} else {
store_orders_itemsElements[store_orders_itemsSumPriceID].value = Math.round(Summ*100)/100;
}
}
document.store_orders_items.Total_price.value = Math.round(TotalSum*100)/100;
}
|
 |
 |
jokecoat
Posts: 43
|
| Posted: 09/12/2008, 5:41 AM |
|
tnx.
|
 |
 |
|