April 27th, 1999, 08:45 AM
The error I get is (this line) "'value' is not a number"
document.input.f_stot.value= decimal(document.input.f_tot0.value * 1 + document.input.f_tot1.value * 1 + document.input.f_tot2.value * 1 + document.input.f_tot3.value * 1 + document.input.f_tot4.value * 1 + document.input.f_tot5.value * 1);
thanks for any help!
April 28th, 1999, 12:21 AM
It's hard to tell what exactly is going on here without seeing it in context, but...
var input0 = parseFloat(document.input.f_tot0.value)
You could also put parseFloat() around each of your values right when you do the calculation, rather than assigning them to a variable as I showed you above.
I assume you were multiplying each by one in attempt to convert them to numbers. Doing so is not necessary (since it won't work anyway).
April 28th, 1999, 09:12 AM
I tried your recommendation and it worked great in IE3 which is where I was getting my error. But the same code gives me a NaN total in N4.5 which had no trouble with my original code.
newtotal = parseFloat(document.input.f_tot0.value) + parseFloat(document.input.f_tot1.value) + parseFloat(document.input.f_tot2.value) + parseFloat(document.input.f_tot3.value) + parseFloat(document.input.f_tot4.value) + parseFloat(document.input.f_tot5.value);
I hate to put a "use 4.0 or higher" but I will if I have too!
April 28th, 1999, 12:39 PM
Since you've already converted your strings to numbers when you totaled them, you shouldn't need to do anything to the contents of your newtotal variable.
So, your next-to-the-last line of code should simply be:
document.input.f_stot.value = newtotal;
April 28th, 1999, 01:07 PM
"decimal" is a function:
// turn to decimal
string = "" + num;
number = string.length - string.indexOf('.');
if (string.indexOf('.') == -1)
return string + '.00';
if (number == 1)
return string + '00';
if (number == 2)
return string + '0';
if (number > 3)
the same total is repeated in form.f_stot and form.finalTotal
April 28th, 1999, 03:13 PM
I made a minimal page in which to test your code, with six text input boxes to enter numbers in, and two fields to show the total. It worked fine in both IE 4 and Netscape 4.5.
So it seems that if you're still having problems, they are caused by something elsewhere in your page and/or code.