Help! Instead of adding the numbers, I get a string, i.e., 15 + 1 = 151 instead of 16. I have three rows with three columns. Basically A X B = C, D X E = F, and G X H = I where numbers are entered only in the A, D, and G fields. Then on the fourth row I want a total of C, F, and I.
I don't have a problem when A, D, and G are entered with a number or when A and D contain a number.
However, when D is blank or zero and I try to add C and I, the total is not a sum of the numbers but a string, i.e., 15 plus 1 becomes "151".
I'm also trying to keep the fields blank if no numbers are entered in A, D, or G.
Any ideas? Thanks.
My calculation scripts:
Row 1.
var a = this.getField("daysThisYear");
var b = this.getField("ratio1");
var c = this.getField("totalThisYear");
var d = 0;
d = (a.value * b.value);
if (d>0) {c.value = d;}
else {if (d<=0) {c.value = ("")}}
Row2.
var a = this.getField("daysLastYear");
var b = this.getField("ratio2");
var c = this.getField("totalLastYear");
var d = 0;
d = (a.value * b.value);
if (d>0) {c.value = d;}
else {if (d<=0) {c.value = ("")}}
Row3.
var a = this.getField("days2YearsAgo");
var b = this.getField("ratio3");
var c = this.getField("total2YearsAgo");
var d = 0;
d = (a.value * b.value);
if (d>0) {c.value = d;}
else {if (d<=0) {c.value = ("")}}
Row4 Total field.
var a = this.getField("totalThisYear");
var b = this.getField("totalLastYear");
var c = this.getField("total2YearsAgo");
var d = this.getField("totalAllYears");
var e = 0;
e = (a.value + b.value + c.value);
if (e>0) {d.value = e;}
else {if (e<=0) {d.value = ("")}}
e = (+a.value + +b.value + +c.value);
A blank field value will get converted to zero (0), so it will result in numerical addition as you want.