Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It's always like that. Some small thing that gets overlooked.
Copy link to clipboard
Copied
What is calculation?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I even changed spacing in between the minus sign and the words of the field...anything I could possibly think of, to no avail.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
What happens when you enter a value in this field?
Copy link to clipboard
Copied
If you are referring to the "cash owed toreturned" field, it's a read only field. I have other forms that are set up similar (read only for result) just using addition or multiplication.
I changed it to enter a value and it's holding that entry (see screenshots below). I'm going through the video for debugging that was provided earlier. All the dropdown choices for calculations work perfectly, but when entering the script (simplified or custom), not so much...unless it's one of the choices from the dropdown. I deliberately did several trials of that to make sure I knew the proper format for it to work.
Example with and without manual entry:
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It's always like that. Some small thing that gets overlooked.