I have the following custom calculation script. Unfortunately, it is adding the text instead of numbers. What can I do? Thanks!
event.value = this.getField("2071").value + this.getField("2073").value + this.getField("2075").value + this.getField("2077").value + this.getField("2079").value + this.getField("2081").value + this.getField("2083").value + this.getField("2085").value - this.getField("2070").value - this.getField("2072").value - this.getField("2074").value - this.getField("2076").value - this.getField("2078").value - this.getField("2080").value - this.getField("2082").value - this.getField("2084").value;
// test for less than zero
if(event.value < 0)
event.value = 0; //set result to zero
Fortunately JavaScript and Adobe provide some properties, methods, or constrictors to force data to either a string or number.
To force a value to a number, you can use the "Number(sValue)" constrictor, or use either multiplication or division with the unity value to force a numeric operation, think multiply by the number 1.
Since you may use or can use the summing of values of field names you might want to consider using a function and reusing the code for the summing of values.
George Kaiser