Use an Acrobat JavaScript Button to Decrease a PDF Field Value
Question details
Add a button action that decreases the FunCurr PDF form field by one each time the button is pressed.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form contains a button and a numeric field named FunCurr.
- Observed behavior
- Each button press should reduce the value in FunCurr by one.
Open the PDF in a version of Adobe Acrobat that can edit form fields. Confirm that the target field is named FunCurr and contains a numeric starting value.
Add a Mouse Up JavaScript action to the Acrobat form button
Use this action to subtract one from FunCurr whenever the button is clicked.
In Adobe Acrobat, open the PDF and select Prepare a form from the Tools or All tools menu.
Right-click the form button and choose Properties, then select the Actions tab.
Set the trigger to Mouse Up and the action to Run a JavaScript. Click Add, enter this.getField("FunCurr").value -= 1; and confirm the script.
Close the Properties dialog, select Preview in the form editor, and click the button. Check that FunCurr decreases by one on each click, then save the PDF.

Use WPS Office for everyday document and PDF work
WPS Office is a free, lightweight alternative for everyday document work, with a familiar interface and compatibility with common Microsoft Office formats for easier migration. Use Adobe Acrobat to configure the JavaScript button described above; WPS Office is not a replacement for that Acrobat form action workflow.

Frequently Asked Questions
Where should I put the decrement script?
In Acrobat's Prepare a form tool, open the button's Properties, select Actions, and add the script as a Run a JavaScript action with the Mouse Up trigger.
Does the field name have to be FunCurr?
The name in this.getField("FunCurr") must match the target form field's name. If your field has a different name, replace FunCurr in the script with that name.
What value should the field contain before I click the button?
Enter a numeric starting value in FunCurr, such as 10. Each click will subtract one from that value.
Why does the button work in Acrobat but not in my browser?
Some browser PDF viewers do not support Acrobat form JavaScript. Open the saved PDF in Acrobat or another viewer that supports the action and check that JavaScript is enabled.




