PDF Editing Issues

Fix Adobe Acrobat JavaScript for Same as Above Checkbox in PDF Forms

Elise WilliamsElise Williams Nov 5, 2026 870 views

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.

Fix Acrobat JavaScript for a Same as Above Form Checkbox
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.
Before you start

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.

Solution 1Recommended

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.

1
Access Checkbox Properties

Open your PDF form in Adobe Acrobat and enter 'Prepare Form' mode. Right-click the 'Same as Above' checkbox and select 'Properties'.

2
Add the JavaScript Action

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'.

3
Paste the Corrected Code

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.

4
Verify Field Calculation Order

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.

Update the Checkbox Mouse Up Action JavaScript
Pro Tip: Setting the target fields to 'readonly = true' when the box is checked prevents users from manually typing over the auto-filled shipping address, reducing errors.
Efficient PDF Form Management

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. 1. Open WPS Office: Launch the WPS Office suite on your computer and select 'PDF' from the home screen.
  2. 2. Open Your PDF Form: Click 'Open' and locate the interactive PDF form you wish to fill or edit.
  3. 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.
Seamlessly open, fill, and save interactive PDF forms nativelyHigh compatibility with Adobe Acrobat PDF formatting and standard field propertiesUser-friendly interface to quickly insert text, signatures, and stampsLightweight software footprint with cross-platform support for Windows, Mac, and mobile
microsoft office alternative - wps office

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.