Skip to main content
Participating Frequently
June 20, 2022
Answered

Utilizing a pop-up to show the results of calculations

  • June 20, 2022
  • 1 reply
  • 546 views

I'm not sure how to approach this. I have a one page, can't be more than one page, client financial presentation PDF form. There is no room left on the form to add text or fields. Either by using a rado-button or check-box, once clicked, I want to perform a simple calculation comparison. When the calculations are complete, a message window will pop-up with standard text verbage with the contents of fields and variables imbedded with-in the text. So, I have two questions:

  1. Which pop-up style window would work the best, be it sticky-note, or other.

  2. How do I imbed the contents of several fields and variables with-in the text that is withing the pop-up.

 

Sample pop-up text (italized amounts represent the contents of fields or variables):

"Even though the extra $65 per month would have you debt free 8 months sooner, in reality, you would have spent an extra $10,075 in loan payments just to save $5,492 in loan interest. Do you think we can find a better use of that $65?" 

The $65 is from a field. The rest of the amounts are variables containing the results from calculations.

This topic has been closed for replies.
Correct answer Thom Parker

An easy method is to use the app.alert() function. Here's an article on how to use it.

https://acrobatusers.com/tutorials/popup_windows_part1/

 

You'll need write code to acquire the contents of the fields needed to build the text string, which will then be passed into the app.alert() function. 

 

In JavaScript, strings are stitched together using the "+" symbol. Like this.

 

var strHello = "Hello " + this.getField("FirstName").valueAsText;

app.alert(strHello);

 

This code adds the word "Hello" to the text in the field named "FirstName". Then displays the text to the user in an alert box. 

This article might help you with some of this;

https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm

 

 

 

 

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
June 20, 2022

An easy method is to use the app.alert() function. Here's an article on how to use it.

https://acrobatusers.com/tutorials/popup_windows_part1/

 

You'll need write code to acquire the contents of the fields needed to build the text string, which will then be passed into the app.alert() function. 

 

In JavaScript, strings are stitched together using the "+" symbol. Like this.

 

var strHello = "Hello " + this.getField("FirstName").valueAsText;

app.alert(strHello);

 

This code adds the word "Hello" to the text in the field named "FirstName". Then displays the text to the user in an alert box. 

This article might help you with some of this;

https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm

 

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
TodRico53Author
Participating Frequently
June 20, 2022

Perfect! Thank you. Just needed some direction. Got huge brain fog from a head cold. Soon as that clears up I will try it out and let you know.