Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Calculated Form Field Values Change

Guest
Aug 10, 2017 Aug 10, 2017

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);
TOPICS
Acrobat SDK and JavaScript , Windows
542
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 10, 2017 Aug 10, 2017

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).

Translate
Community Expert ,
Aug 10, 2017 Aug 10, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 10, 2017 Aug 10, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2017 Aug 10, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 10, 2017 Aug 10, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2017 Aug 10, 2017

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 10, 2017 Aug 10, 2017
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines