Calculating sub totals

Hi all,

I have 6 columns of 25 fields + a field for the total.

function do_recalc(fname) {

var i;

var acc=0.0;

var s;

var f=window.document.forms[0];

for(i=0;i<25;i++){

	 var nm="drdf_"+fname+"_" +i;

	s=f[nm].value;

	if (s!="") {

		acc=acc + parseFloat(s);

	}

}

f["drdf_"+fname+"_total"].value=acc;

}

Every field has an onchange event: do_recalc(“receptions”)

In the sixth column the sub total of that row should be shown. Any idea’s?

Regards

EDIT Found a solution.

function calc_row_total(rowno) {

var f = window.document.forms[0];

var acc = 0.0



if (f["drdf_receptions_" + rowno].value != "") {

	acc += parseFloat(f["drdf_receptions_" + rowno].value)

}

if (f["drdf_hotel_rest_" + rowno].value != "") {

	acc += parseFloat(f["drdf_hotel_rest_" + rowno].value)

}

if (f["drdf_frais_tel_" + rowno].value != "") {

	acc += parseFloat(f["drdf_frais_tel_" + rowno].value)

}

if (f["drdf_parking_peages_" + rowno].value != "") {

	acc += parseFloat(f["drdf_parking_peages_" + rowno].value)

}

if (f["drdf_divers_" + rowno].value != "") {

	acc += parseFloat(f["drdf_divers_" + rowno].value)

}



f["drdf_total_journalier_" + rowno].value = acc;

}