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

Subtraction and addition

Explorer ,
Dec 29, 2022 Dec 29, 2022

Copy link to clipboard

Copied

I am looking to have a formula to calculate both addition and subtraction.

I really want the formula to produce the difference between '"a" and "b"

So if field "b" has a value of 1 more than '"a" it returns a postive, if it is less than "a" to return a negative

Is this possible?

 

 

var a = this.getField("WeightOnTag.0.0 ").value;
var b = this.getField("PhysicalWeight.0").value;
event.value = a - b;

TOPICS
Create PDFs , Edit and convert PDFs , JavaScript , PDF forms

Views

240

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 ,
Dec 29, 2022 Dec 29, 2022

Copy link to clipboard

Copied

LATEST

Yes of course it is possible.  You only need to add a conditional to the code you already have. 

However, you haven't specified the complete condtions. 

diff = b-a  

diff > 1  :  Postive result

diff < 0 :  Negative result

what happens between 0 and 1 ? 

 

Read this:

https://acrobatusers.com/tutorials/conditional-execution/

 

 

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