ri**@away32.com wrote:
Here's my code:
function doMath() {
var grandTot=0;
var one=new Array(13);
var two=new Array(13);
var prod=new Array(13);
one[1] = eval(document.form1.BFPpric.value);
two[1] = eval(document.form1.BFPquantity.value);
one[2] = eval(document.form1.BFTTpric.value);
two[2] = eval(document.form1.BFTTquantity.value);
etc down to 13 then
for (var i = 1; i < 14; i++) {
prod[i] = one[i] * two[i];
grandTot += prod[i];
}
}
There will always be some prod[i] in there that will be 0 (zero)
value, because not every item is ordered.
grandTot always totals to 0 (zero)!!!!! WHY??
It's making me nuts!!
I think VK explained pretty nicely, but I wanted to add a tip that may
save you going nuts in future.
Ideally, test just one line of code or portions of it. So for example
in your code, the thing to check before going further is:
eval(document.form1.BFPpric.value);
And if you kept getting 0 as an answer regardless of what value you put
in your form field, you would know that there maybe something wrong
with the way you're trying to retrieve the values.
This would probably have led you to the conclusion that eval() is not
giving you the answers you expect and you'd have searched the net for
its proper use or for an alternative way of extracting form field
values.
It may seem trivial to you at this point, but believe me, when your
scripting starts to get more and more complex, you'll appreciate this
kind of approach.