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?

try67
Adobe Expert
April 19, 2019

I see! Thank you. So once I've opened the "Text Field Properties" box, hovered over to "Actions", would the select action be "Run a JavaScript"? If so, do you mind assisting me with the wording of the formulas I am attempting to create. I would like the following formulas to be created:

Computer Purchase Program               Cost

          A.                                             *user inputted quantity*

          B.                                             A. times .20

          C.                                             A. minus B.

          D.                                             *user inputted quantity*

          E.                                             C. divided by D.


No, it's not under Actions. It's under the Calculate tab.