PDF Editing Issues

How to Conditionally Copy Text Between PDF Form Fields

Huma Ashraf ChHuma Ashraf Ch Oct 28, 2026 868 views

Question details

The user wants to copy a value from one PDF form field (e.g., Height1) to others (Height2, Height3), but only if corresponding reference fields (UPC2, UPC3) are not blank.

How to Conditionally Copy Text Between PDF Form Fields
Product
PDF Editor
Device & OS
not provided
Scenario
Creating dynamic PDF forms with conditional logic for auto-filling fields.
Observed behavior
Destination fields need to dynamically update based on the presence of values in related reference fields, remaining blank when the reference fields are empty.
Before you start

Determine if the destination fields should be read-only or if users need the ability to manually overwrite the automatically copied values. Ensure you have a PDF editor that supports adding custom JavaScript or calculation scripts to form fields.

Solution 1Recommended

Use Custom Calculation Scripts in PDF Form Fields

Apply a custom JavaScript calculation to the destination fields to check the status of related fields before copying data.

This method uses basic JavaScript to evaluate whether the reference field is empty. If it contains data, the script fetches the value from the source field and copies it to the destination field.

1
Open Form Field Properties

Open your PDF in form editing mode, right-click the destination field (e.g., Height2), and select 'Properties'.

2
Access Calculation Settings

Navigate to the 'Calculate' tab in the Properties window and select the 'Custom calculation script' option.

3
Enter the JavaScript

Click 'Edit' and enter the following script logic: if (this.getField('UPC2').valueAsString !== '') { event.value = this.getField('Height1').valueAsString; } else { event.value = ''; }

4
Apply to Other Fields

Repeat the process for the next destination field (e.g., Height3), updating the script to check the respective reference field ('UPC3'). Save your PDF to test the logic.

Use Custom Calculation Scripts in PDF Form Fields
Editable vs Read-Only: If you want the copied values to be permanent and unchangeable by the user, go to the 'General' tab in the field properties and check the 'Read-Only' box.
Advanced PDF Form Editing

Create and Manage Dynamic PDF Forms with WPS Office

WPS Office provides robust PDF editing tools, making it easy to design interactive forms, manage form fields, and handle document workflows efficiently without relying on complex standalone software.

  1. 1. Open PDF in WPS: Launch WPS Office and open your PDF document containing the form fields.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to view all available form editing options.
  3. 3. Edit Field Properties: Double-click any text field to open its properties, where you can configure formatting, actions, and calculation rules.
  4. 4. Save the Form: Once your conditional logic is set up, click 'Save' to preserve the interactive form fields.
Comprehensive PDF form field creation and property management.Fully compatible with standard PDF forms and Adobe Acrobat formats.Lightweight, fast, and easy-to-use interface for modifying PDFs.Seamlessly edit text, images, and pages within your PDF documents.
microsoft office alternative - wps office

Frequently Asked Questions

Can I use basic calculations instead of custom scripts?

Basic calculations (like Sum or Product) are built into most PDF editors, but conditional logic (checking if another field is blank) requires a custom JavaScript calculation.

Why is the destination field not updating when I type?

Form fields typically update when you exit or 'commit' the current field. Press 'Enter' or click outside the reference field to trigger the calculation script.

How do I prevent users from changing the auto-filled text?

In the form field properties, go to the General tab and select the 'Read-Only' checkbox. This prevents manual editing of the field once the script has populated it.

Are JavaScript calculations supported in all PDF viewers?

Most standard desktop PDF viewers support JavaScript, but some mobile apps or browser-based viewers might strip out or ignore advanced form scripts. Always test your form in the intended viewer.