How to Autofill Acrobat Form Fields After a Check Box Selection
Question details
The user wants to automatically populate specific fields in a PDF form with existing data when a check box is selected, and clear the data when it is deselected.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where certain fields replicate data (such as a 'Shipping same as Billing' option) based on user interaction.
- Observed behavior
- Needs a method to trigger data copying between defined form fields dynamically upon checking a box, including logic to reverse the action.
Ensure you have noted the exact field names for both the source data fields and the destination fields before you begin writing your script, as JavaScript is case-sensitive.
Configure a Mouse Up Action with Custom JavaScript
Use Adobe Acrobat's built-in JavaScript capabilities to detect the checkbox state and copy data between fields accordingly.
By applying a custom script to the check box's properties, you can command the form to extract values from source fields and insert them into target fields whenever the user releases their mouse button over the check box.
Enter 'Prepare Form' mode in Adobe Acrobat, right-click the target check box, and select 'Properties' from the context menu.
Click on the 'Actions' tab at the top of the Properties dialog box. Set the 'Select Trigger' dropdown to 'Mouse Up'.
In the 'Select Action' dropdown, choose 'Run a JavaScript', then click the 'Add...' button to open the JavaScript editor window.
Write a script that checks the event value. For example: if (event.target.isBoxChecked(0)) { this.getField('TargetField').value = this.getField('SourceField').value; } else { this.getField('TargetField').value = ''; }. Click OK to save.
Create and Fill Interactive PDF Forms with WPS Office
WPS Office provides robust and intuitive PDF tools, allowing you to seamlessly create, edit, and fill interactive PDF forms without the need for complex enterprise software.
- 1. Open your PDF: Launch WPS Office and open the PDF document you wish to edit or fill.
- 2. Access Form Tools: Navigate to the 'Form' tab in the top ribbon to access the suite of interactive form controls.
- 3. Insert Form Fields: Select the 'Check Box' or 'Text Field' tool and drag on the document page to place your new field.
- 4. Edit Properties: Double-click the inserted field to modify its name, appearance, and specific interactive properties.

Frequently Asked Questions
Why isn't the data clearing when I uncheck the box?
Your JavaScript needs an 'else' condition to handle the deselected state. If the check box is toggled off, you must explicitly instruct the script to set the target field values to an empty string (e.g., '') to clear them.
How do I find the exact field names in my PDF form?
While in the form editing mode (like 'Prepare Form'), field names are usually displayed directly over the form elements. You can also double-click any field to open its Properties dialog, where the exact 'Name' is listed on the General tab.
Will this JavaScript autofill work on all PDF readers?
Advanced PDF JavaScript is fully supported in Adobe Acrobat and full-featured PDF editors. However, it may not function correctly in basic web browser PDF viewers or mobile previewers, so advise your users to download the file and open it in a dedicated desktop application.




