6 Replies Latest reply on Aug 10, 2017 10:34 AM by ubelongoutside

# Calculated Form Field Values Change

Hi,

I have a formula for calculating the %CV of a set of values.  The formula is below.  The problem is that if you enter another value in one of the "fill" cells and then change it back to the original number you end up with a different calculated value.  Also if you delete the contents of the calculated cell and then click or tab out of it the value also changes.  Any idea what can be the root cause here?

var average = this.getField("Text10").value;

var v = 0;

var fieldName = "fill";

var s = 0;

var sd = 0;

n = 6;

for (var i = 0; i < n; i++) {

v = this.getField(fieldName + i).value;

s = s + Math.pow((v - average), 2);

}

sd = ((Math.sqrt(s / n)) / average);

1. event.value = sd;
2. event.value = util.printf("%.2f", event.value);
• ###### 1. Re: Calculated Form Field Values Change

Why is that a problem? The calculation script gets executed each time the value of any field in the file changes. That's how it is supposed to work.

• ###### 2. Re: Calculated Form Field Values Change

Sorry, maybe my explanation wasn't clear.

So if i have a series of values in there.  Let's say 1,2,3,4,5,6 I get a CV value of 0.79.  If I change the 1 to a 2 the CV changes to 0.43, but if I then change the 2 back to a 1 the CV recalculates as 0.47 instead of 0.79.

Same thing if I have the same series in there 1,2,3,4,5,6 the CV is calculated as 0.79, but if I clear the calculated value and then click elsewhere in the sheet the value is re-calculated as 0.49 even though none of the input values have changed.

• ###### 3. Re: Calculated Form Field Values Change

Are the values of these fields calculated as well, or are they entered by the user manually? What about the "average" field?

• ###### 4. Re: Calculated Form Field Values Change

Fill0 through Fill5 are entered manually.  The average is calculated using the average function of the calculate tool within Acrobat and is the "Text10" argument in the CV calculation

• ###### 5. Re: Calculated Form Field Values Change

You need to make sure that the Average field is calculated before this field. You'll be able to set the calculation order in Form Edit mode, under More (or Other Tasks if you have an earlier version of Acrobat).

• ###### 6. Re: Calculated Form Field Values Change

Awesome! Thanks for the help.  I thought it might be something simple but didn't think about that.