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

second field auto populates with 2.5% of that number in first field.

Participant ,
Feb 13, 2018 Feb 13, 2018

Copy link to clipboard

Copied

I enter into one field a dollar amount. Then a second field auto populates with 2.5% of that number in first field.

TOPICS
PDF forms

Views

488

Translate

Translate

Report

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
1 ACCEPTED SOLUTION
Community Expert ,
Feb 13, 2018 Feb 13, 2018

Copy link to clipboard

Copied

First, you need to understand the math.

What you want is this, correct?

B = .025 * A

So your code needs to be placed in the calculation script for field B.

event.value = this.getField("A").value * 0.025;

You can learn more about JavaScript and calculations here:Calculating field values and more

And you'll find an example PDF with calculations here (about halfway down the page):Free Sample PDF Files with scripts

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Votes

Translate

Translate

Report

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 ,
Feb 13, 2018 Feb 13, 2018

Copy link to clipboard

Copied

Have you a question?

Votes

Translate

Translate

Report

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
Participant ,
Feb 13, 2018 Feb 13, 2018

Copy link to clipboard

Copied

Sorry, guess it was the way I formed it.

If I type a dollar amount into field A, I want it to calculate 2.5 % of that amount and put it in field B. How is this done. I tried this, but does not work.

event.value = Number(this.getField("A").value) * (Number(this.getField("B").value)/2.5);

Votes

Translate

Translate

Report

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 ,
Feb 13, 2018 Feb 13, 2018

Copy link to clipboard

Copied

First, you need to understand the math.

What you want is this, correct?

B = .025 * A

So your code needs to be placed in the calculation script for field B.

event.value = this.getField("A").value * 0.025;

You can learn more about JavaScript and calculations here:Calculating field values and more

And you'll find an example PDF with calculations here (about halfway down the page):Free Sample PDF Files with scripts

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
Participant ,
Feb 13, 2018 Feb 13, 2018

Copy link to clipboard

Copied

I understand what I want, just not sure of syntax. What you gave me is 100% perfect. Plus the link you sent, very helpful. Thank you.

Now, go buy a lotto ticket and win BIG!!!!

Votes

Translate

Translate

Report

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 ,
Feb 13, 2018 Feb 13, 2018

Copy link to clipboard

Copied

You can use this simplified notation:

0.025 * A

Votes

Translate

Translate

Report

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
Participant ,
Feb 13, 2018 Feb 13, 2018

Copy link to clipboard

Copied

LATEST

even better

Votes

Translate

Translate

Report

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