PDF Editing Issues

How to Automatically Copy Form Data When a Checkbox Is Selected in PDF

Tauseeq MagsiTauseeq Magsi Oct 28, 2026 869 views

Question details

The user wants to automatically copy inputted values from one set of PDF form fields to another related set (like billing to shipping address) when a specific checkbox is ticked.

How to Automatically Copy Form Data When a Checkbox Is Selected in a PDF
Product
PDF Editor
Device & OS
not provided
Scenario
Creating interactive PDF forms where users often need to duplicate identical information across different sections.
Observed behavior
The user needs to implement a JavaScript trigger on a checkbox to automate form filling while allowing manual overwrites if needed.
Before you start

Ensure that your PDF document already contains all the necessary source and destination text fields, and that each field has a unique and identifiable name.

Solution 1Recommended

Add a MouseUp JavaScript to the Checkbox

Attach a simple JavaScript code to the checkbox's action properties to copy values from the source fields to the destination fields automatically.

By configuring the checkbox properties in your PDF editor, you can trigger a custom script whenever the user clicks the box. The script retrieves the string value from your primary fields and pastes it into the secondary fields.

1
Open Checkbox Properties

Right-click the targeted checkbox in your PDF form editing mode and select 'Properties' from the context menu.

2
Set the Action Trigger

Navigate to the 'Actions' tab. Select 'Mouse Up' from the 'Select Trigger' dropdown menu, and choose 'Run a JavaScript' from the 'Select Action' menu. Click the 'Add' button.

3
Input the JavaScript Code

In the JavaScript Editor window, enter the following code: if (event.target.value != "Off") { this.getField("FirstName2").value = this.getField("FirstName1").valueAsString; this.getField("LastName2").value = this.getField("LastName1").valueAsString; } Customize the field names to match your form.

4
Save and Test

Click 'OK' to save the script, close the properties window, and test your form to ensure the data copies correctly when the box is checked.

Add a MouseUp JavaScript to the Checkbox
Manual Overwrites: This script only triggers when the checkbox is clicked. Users can still manually edit the copied values in the destination fields without affecting the source fields.
Powerful PDF Editor

Create and Manage Interactive PDF Forms with WPS Office

WPS Office provides robust PDF editing capabilities, enabling you to easily insert checkboxes, manage text fields, and streamline data collection for your interactive forms.

  1. 1. Open your PDF Document: Launch WPS Office and open the PDF file you wish to make interactive.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access the interactive form creation tools.
  3. 3. Insert Form Fields: Select the checkbox or text field tool and click on the document to place them exactly where you need.
  4. 4. Customize Properties: Double-click the inserted fields to rename them and adjust their properties for data collection.
Easily insert interactive elements like checkboxes and text fieldsFully compatible with standard Adobe PDF form formatsLightweight architecture for fast PDF rendering and editingIntuitive user interface for seamless document management
microsoft office alternative - wps office

Frequently Asked Questions

Can I copy data across multiple fields with one checkbox?

Yes, you can copy data to as many fields as necessary by adding additional lines inside the same 'if' statement in your JavaScript, such as this.getField("Address2").value = this.getField("Address1").valueAsString;

What happens if the user unchecks the box?

The provided script only copies data when the checkbox is selected. If you want the destination fields to clear when unchecked, you will need to add an 'else' statement to your JavaScript that sets the destination field values to empty strings.

Why is my JavaScript not working in the PDF?

Ensure that the field names referenced in your script perfectly match the actual names of the fields in your document. JavaScript is case-sensitive, so 'firstname1' is different from 'FirstName1'.