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

Custom Calculation Script Based On Custom Calculation Script

New Here ,
May 06, 2017 May 06, 2017

Hello,

I'm having some troubles with calculating something (This is for a DnD pdf).

I have already gotten loads of scripts working, but my big trouble is when I have a Custom Calculation Script that is dependent upon another Custom Calculation Script to calculate a number...

Let's assume I have:

a) A user input field, called "Dexterity".       (Could store the value: 16)

b) Is a Custom Calcution Script (Let's call it "Modifier" that depends on "Dexterity",

to calculate its value.   (("DEX" - 10) / 2)      (Calculated would be: 3)

My script (Simplified) would be:

event.value = (this.getField("Dexterity").value - 10) / 2;

c) A field (Let's call it "Stealth") that calculates a total value from the "Modifier"

and another User Input Field.     (Such as above value + 2 from the User Input Field, total: 5)

My script (Simplified) would be:

event.value = this.getField("Modifier").value + this.getField("NewUserInput").value;

The problem here is c) ("Stealth")

It simply will not calculate it, if it's based on another calculation script ("Modifier"), but will do it, if I use the code from the b) ("Modifier") calculation.

This would not be a problem, of course, except for the fact that I might have an additional changes to the value of "Modifier" based on something different in the sheet´.

I hoped this would work, so it calculate everything very dynamically and nice, but this problem has stumped me for the last 5-6 hours, and I simply don't know what to google to see if anyone has the same problem as me..

Thanks in advance!

Best Regards.

TOPICS
Acrobat SDK and JavaScript
708
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 ,
May 07, 2017 May 07, 2017

Check the calculation order.

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
New Here ,
May 07, 2017 May 07, 2017

I don't completely understand what you mean?

Can you give me an example of what you are trying to say, or an example where you calculate something from another calculation field, so I know it's possible?

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 ,
May 07, 2017 May 07, 2017
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
New Here ,
May 07, 2017 May 07, 2017

Okay, perfect. Thank you very much for that, I had no idea what to search for

Is there a way to force a "refresh" of calculated values, when an input changes (Such as when you select a value using a dropdown box).


Currently I need to press a checkbox, for example, before all the values will calculate.

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
LEGEND ,
May 07, 2017 May 07, 2017
LATEST

Usually all calculations are refreshed when one changes and field used in a calculation and exits the changed field.  You should be able to click any place on the form page and all the calculations should refresh.

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