Fix Adobe Acrobat JavaScript for Same as Above Checkbox in PDF Forms
Question details
The user needs to correct the JavaScript code in an Adobe Acrobat PDF form so that selecting a 'Same as Above' checkbox successfully copies the billing name and address into the corresponding shipping fields.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Designing or editing an interactive PDF form that requires auto-filling duplicate information via a checkbox toggle.
- Observed behavior
- The existing JavaScript linked to the checkbox fails to execute properly, preventing the customer name and address data from being copied into the shipping fields.
Ensure you have the exact case-sensitive names of all the text fields in your PDF form (e.g., 'Name', 'Nameofshipping') before editing the script, as incorrect field names will cause the JavaScript to fail.
Update the Checkbox Mouse Up Action JavaScript
Apply a corrected JavaScript snippet to the checkbox's 'Mouse Up' trigger to copy values when checked, clear them when unchecked, and manage the read-only states of the destination fields.
To make the 'Same as Above' checkbox function correctly, the script must verify whether the checkbox is checked (not 'Off'). When checked, it fetches the values from the source fields and assigns them to the destination fields.
It is also best practice to lock (make read-only) the shipping fields while the checkbox is active to prevent users from accidentally altering the copied data.
Open your PDF form in Adobe Acrobat and enter 'Prepare Form' mode. Right-click the 'Same as Above' checkbox and select 'Properties'.
Navigate to the 'Actions' tab. Select 'Mouse Up' from the 'Select Trigger' drop-down menu. Then, choose 'Run a JavaScript' from the 'Select Action' drop-down menu and click 'Add'.
In the JavaScript Editor window, paste the following code: if (event.target.value != "Off") { this.getField("Nameofshipping").value = this.getField("Name").value; this.getField("Addressofshipping").value = this.getField("Address").value; this.getField("Address2ofshipping").value = this.getField("Address2").value; this.getField("Nameofshipping").readonly = true; this.getField("Addressofshipping").readonly = true; this.getField("Address2ofshipping").readonly = true; } else { this.getField("Nameofshipping").value = ""; this.getField("Addressofshipping").value = ""; this.getField("Address2ofshipping").value = ""; this.getField("Nameofshipping").readonly = false; this.getField("Addressofshipping").readonly = false; this.getField("Address2ofshipping").readonly = false; } Click 'OK' to save the script.
If your form contains other calculated fields, go to 'More' > 'Clear Form' and then check the calculation order in the form editing menu to ensure the dependent fields update in the correct sequence.

Easily Edit and Fill PDF Forms with WPS Office
If you are looking for a highly compatible and intuitive tool to manage, fill, and edit PDF forms without the complexity of advanced scripting, WPS Office offers a powerful built-in PDF editor tailored for everyday business needs.
- 1. Open WPS Office: Launch the WPS Office suite on your computer and select 'PDF' from the home screen.
- 2. Open Your PDF Form: Click 'Open' and locate the interactive PDF form you wish to fill or edit.
- 3. Fill and Save: Click directly into the form fields to add your information. Once completed, go to Menu > Save to preserve your form data securely.

Frequently Asked Questions
Why is my PDF form JavaScript not executing when I click the checkbox?
JavaScript might be disabled in your PDF viewer's security preferences. In Acrobat, go to Edit > Preferences > JavaScript and ensure that 'Enable Acrobat JavaScript' is checked. Additionally, double-check that your field names in the code match the actual field names exactly, as they are case-sensitive.
How do I find the exact field names used in my PDF form?
While in the 'Prepare Form' mode, double-click on any text field or checkbox to open its Properties window. The exact field name will be listed under the 'General' tab.
Can I use this same JavaScript for a drop-down menu instead of a checkbox?
Yes, but you will need to adjust the trigger logic. Instead of checking if the event target is not equal to 'Off', you must write the condition to evaluate the specific selected text value of your drop-down menu (e.g., if (event.target.value == 'Use Billing Address')).
Why do the destination fields not clear when I uncheck the box?
This usually happens if the 'else' statement in the JavaScript is missing, improperly formatted, or if the field names in the 'else' block do not match. Review the code to ensure the `this.getField("FieldName").value = "";` lines are correctly targeting your destination fields.




