In article <63f32a46.0312151654.3c270c0e@posting.google.com >,
yellowbirdprods@hotmail.com enlightened us with...[color=blue]
>
> I need a script that will count the number of rows in the text column
> (with data only) and add the values in the numeric columns, changing
> the value in the Totals row as entries are made (or removed).
>
> Any examples or suggestions are greatly appreciated.
>[/color]
The best way to do this is to name all the boxes you want in the total
with a particular name, then loop through the form when the element
changes and get the total of the ones that have numbers in them.
For example, you name all the boxes you want in the total with "T_" and
NO other elements have that in the name.
So you have
T_1
T_2
T_3
T_4
T_5
....
and so on.
Each one of these has an onChange that calls a function, call it
getTotals() or something.
<input type="text" name="T_1" onChange="getTotals()">
I'll assume the form is named form1 for convenience.
I'll assume the total element where you want it written is named
"total".
(watch for word-wrap)
function getTotals()
{
var total = 0;
var L = document.forms["form1"].elements.length;
for (var i=0; i<L; i++)
{
if (document.forms["form1"].elements[i].name.indexOf("T_")[color=blue]
> -1 && !isNaN(document.forms["form1"].elements[i].value))[/color]
{
total += parseFloat(document.forms["form1"].elements
[i].value);
}
}
document.forms["form1"].elements["total"].value = total;
return;
}
I didn't test this, so there may be a typo. It's early. :)
--
--
~kaeli~
She was engaged to a boyfriend with a wooden leg but broke
it off.
http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace