Skip to main content
New Participant
April 9, 2019
Question

How to add automated calculated fields.

  • April 9, 2019
  • 2 replies
  • 11849 views

Hello Everyone,

I am currently using Adobe Acrobat XI Pro and am having trouble adding automated calculated fields. The formula I am looking to add is very simple. This is the general framework I am looking to create:

A: Total cost of computer ___________________ (dollar amount inserted by user)

B: Less 20% _____________________________ (formula would automatically multiply the dollar amount entered by 80%)

C: Total loan amount _______________________ (A minus B will be automatically computed)

😧 Amount of terms ________________________ (term quantity will be entered by user)

E: Biweekly deduction ______________________ (C divided by D will be automatically computed)

As you can see, I would like three of these fields to be automated, making the user experience with the PDF file a smooth and seamless function.

Thank you in advance for any guidance provided.

This topic has been closed for replies.

2 replies

New Participant
March 6, 2020

code for field B:   this.getField("less20").value = this.getField("totalCost").value * 0.20;   

code for field C:    this.getField("totalLoan").value = this.getField("totalCost".value - this.getField("less20").value;

code for field E:

if (!Math.trunc) {
Math.trunc = function (v) {
return v < 0 ? Math.ceil(v) : Math.floor(v);
};

}

this.getField("biWeeklyDed").value = Math.trunc(this.getField("totalLoan").value  / this.getField("termQty").value);

 

TMacFarlane
Participating Frequently
August 12, 2020

This worked for me! Thanks very much—just needed to figure out how to write the code, and this post showed me what the JS formatting would look like in the Custom field. Thanks for this help!

Thom Parker
Adobe Expert
April 10, 2019

Here's an article on using PDF form calculations.

https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations

I think you could do your calculations with "Simplified Field Notation"

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
New Participant
April 11, 2019

Thank you for responding Thom. Unfortunately my Content Editor only shows the following actions:

  • Edit Text & Images
  • Add Text
  • Add Image
  • Export File to...

More Content

  • Add or Edit Link
  • Add Bookmark
  • Attach a File

Maybe I need to download add-ins?

Thom Parker
Adobe Expert
April 16, 2019

Hey Thom,

This is what my Tools section looks like. I'm assuming it is an older version which is causing my confusion. What would the steps be to find "Prepare Form" and to then add the Simplified Field Notation?

Thank you in advance!


Click on the "Forms" tool, then select "Edit.

This will display a toolbar for adding fields. Fields placed on the form will be outlined the fields with the field names visible. Double click on a field to display the properties dialog, where you will be able to add actions and scripts to the field.

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