Skip to main content
Participating Frequently
August 21, 2023
Answered

Field needs to be filled by user for difference calculation

  • August 21, 2023
  • 4 replies
  • 1260 views

I need a difference calculation provided (positive or negative). An amount entered by a form user to calculate the difference. This is the information required on form:

 

 

The user would enter the "Advanced Check Amount" and the "Cash owed toreturned" needs to show the difference, be it positive or negative. (Amount1-3  boxes are misc expenses)

Definitely not a pro here, so forgive me if it's something Captain Obvious would know lol.

I've exhausted research options and just want to know if this is possible or not. Thanks for anyone's help.

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

It's always like that. Some small thing that gets overlooked. 

 

4 replies

Participating Frequently
August 28, 2023

One word was missing from my formula. I overlooked it so many times. The formula is working now. User error...most definitely. Thank y'all for the help.

 

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
August 28, 2023

It's always like that. Some small thing that gets overlooked. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participating Frequently
August 21, 2023

The screenshot at the bottom will show what I'm looking for, I hope. I did a formula prior to posting here and could not get it to work. 

 

The small column on the left is for Misc Expenses incurred and the Meals total is the top. All my auto calculations work except for getting the amount that is "owed" or needs to be "returned" to the traveler. So in my screenshot, all the variables are correct and in place to calculate that final number, be it positive cash (owed to traveler) or negative cash (traveler must return).

If this is clear as mud, please accept my apologies. Sometimes the smallest of things can cause the greatest of problems for someone, and I feel like that is where I'm at.

 

 

Participating Frequently
August 21, 2023

I even changed spacing in between the minus sign and the words of the field...anything I could possibly think of, to no avail.

Thom Parker
Community Expert
Community Expert
August 21, 2023

Spacing is meaningless.  To find out whats going on the first thing you need to do is look in the console window to see if there are any repported errors.  Press "Ctrl-J" to display the console. 

Here's a video tutorial on how to use it. 

https://www.pdfscripting.com/public/images/video/AcroJSIntro/AcroJSIntro_ConsoleWindow.cfm

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
August 21, 2023

This is a simple calculation. With Acrobat JavaScript it is possible to perform much, much more complicated operations.

You can read about simple scripting for calculations here:

https://www.pdfscripting.com/public/How-to-Write-a-Basic-PDF-Calculation-Script.cfm

 

You're ("Cash owed toreturned") calculation script might look something like this: 

 

 

event.value = this.getField("Advanced Check Amount").value - this.getField("Total Expenses").value;

 

 

However, to get the calculation correct we'd need to know exactly what fields are involved and how. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Nesa Nurani
Community Expert
Community Expert
August 21, 2023

What is calculation?