Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Exit

1

/t5/acrobat-discussions/simple-calculation-script/td-p/14757001
Jul 24, 2024
Jul 24, 2024

Copy link to clipboard

Copied

Hi! I'm pretty new to the idea of making calculation scripts in Adobe Acrobat, just to preface.

I'm trying to calculate the Time Value of Money and when I do the calculation with only the numbers it works out perfectly but as soon as I plug in my variables that equal those numbers my calculation no longer gives me the number it's supposed to. Here's the script I'm working with as a Simplified Field Notation.

c2 * ( 1 + 0.05 / 1 ) ^ 67 - Nn + a1 * c1 /0.05 ( ( 1 + 0.05 / 1 ) ^ 67 - Nn -1) * 1

Nn = 30

a1 = 50,000

c1 = 10%

c2 = 1,000

I appreciate any help, thanks!

TOPICS

General troubleshooting
,
JavaScript
,
PDF forms

Community guidelines

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

Community Expert
,
Jul 24, 2024
Jul 24, 2024

- You forget the .valueAsString part in the definitions of the variables.

- Not sure why you stuck event.value in the middle of the last line. It needs to be at the start of it.

- Since your formula is a bit complex I would recommend splitting it into parts. Each part can be defined as a variable and then use later on in the final calculation.

6
Replies
6

/t5/acrobat-discussions/simple-calculation-script/m-p/14757030#M472014
Jul 24, 2024
Jul 24, 2024

Copy link to clipboard

Copied

You can't use the Simplified Field Notation if you need to use the Power operator. You must use a script.

And the way to do that in JS is with this command:

Math.pow(x,y)

This will return x^y.

Also, you need to make sure that the value of your percentage field is not 10 but 0.1, for the calculation to work correctly.

Community guidelines

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

Reilly.H
AUTHOR

Community Beginner
,

/t5/acrobat-discussions/simple-calculation-script/m-p/14757058#M472024
Jul 24, 2024
Jul 24, 2024

Copy link to clipboard

Copied

Community guidelines

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

/t5/acrobat-discussions/simple-calculation-script/m-p/14757068#M472027
Jul 24, 2024
Jul 24, 2024

Copy link to clipboard

Copied

Not much... You just need to define the variables, and use the correct operators (except for Power they are all the same as in the Simple Notation), and apply the result to event.value at the end.

Here's a simple example:

var A = Number(this.getField("A").valueAsString);

var B = Number(this.getField("B").valueAsString);

event.value = Math.pow((A * B) / 400, 2);

This is the same as: ((A * B) / 400) ^ 2

See here for some more info: https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations

Community guidelines

Reilly.H
AUTHOR

Community Beginner
,

/t5/acrobat-discussions/simple-calculation-script/m-p/14757322#M472051
Jul 24, 2024
Jul 24, 2024

Copy link to clipboard

Copied

Thank you. I've been working on it a bit more and this is what I have. It's still not coming up with any numbers.

var Cc = Number(this.getField("Cc")); console.println("Cc "+ Cc); var Ca = Number(this.getField("Ca")); var a1 = Number(this.getField("a1")); var Nn = Number(this.getField("Nn")); var first_pwr = Math.pow( event.value = Math.pow((Ca * ( 1 + 0.05 / 1 ) , ( 67 - Nn ) + ( a1 * Cc ) / 0.05 * ( ( 1 + 0.05 / 1 ) ,( 67 - Nn ) - 1 ) * 1 ));

Community guidelines

/t5/acrobat-discussions/simple-calculation-script/m-p/14757348#M472052
Jul 24, 2024
Jul 24, 2024

Copy link to clipboard

Copied

- You forget the .valueAsString part in the definitions of the variables.

- Not sure why you stuck event.value in the middle of the last line. It needs to be at the start of it.

- Since your formula is a bit complex I would recommend splitting it into parts. Each part can be defined as a variable and then use later on in the final calculation.

Community guidelines

Reilly.H
AUTHOR

Community Beginner
,

LATEST
/t5/acrobat-discussions/simple-calculation-script/m-p/14757474#M472059
Jul 24, 2024
Jul 24, 2024

Copy link to clipboard

Copied

That worked! Thank you!

Community guidelines

Resources

About Adobe Acrobat

Adobe Inc

Adobe Inc

Adobe Inc

Adobe Inc

Adobe Acrobat Feature & Workflow

FAQs

Copyright © 2024 Adobe. All rights reserved.