PDF Editing Issues

How to Use a Checkbox to Fill Empty PDF Fields with Default Text

Natalie TaylorNatalie Taylor Nov 5, 2026 869 views

Question details

The user needs a way to automatically populate a group of numbered, empty PDF fields with a default word (like "EMPTY") by clicking a checkbox.

How to Use a Checkbox to Fill Empty PDF Fields with Default Text
Product
PDF
Device & OS
not provided
Scenario
Automating PDF form completion to mark skipped or blank grouped fields (e.g., Weight1 through Weight14) with a default placeholder without affecting previously entered data.
Observed behavior
When the specific checkbox is selected, only the currently blank fields in the numbered group should be filled with the default text.
Before you start

Ensure you have access to a PDF editor with form scripting capabilities (such as Adobe Acrobat or WPS Office PDF) and verify the exact names of your sequential form fields.

Solution 1Recommended

Add a JavaScript Action to the Checkbox

Use a custom JavaScript loop triggered by the checkbox's Mouse Up event to check and fill empty fields automatically.

By applying a short JavaScript snippet to your checkbox properties, you can iterate through a numbered sequence of text fields. The script will verify if the checkbox is active and if the target field is currently empty before applying your default text.

1
Open Checkbox Properties

Open your PDF document in form editing mode, right-click the specific checkbox you want to use as a trigger, and select 'Properties'.

2
Add a JavaScript Action

Navigate to the 'Actions' tab. Select 'Mouse Up' from the Select Trigger dropdown. Then, select 'Run a JavaScript' from the Select Action dropdown and click the 'Add' button.

3
Enter the Script

In the JavaScript Editor window, input the following code: for (var i = 1; i <= 14; i++) { if (event.target.value != "Off" && this.getField("Weight" + i).value == "") { this.getField("Weight" + i).value = "EMPTY"; } }

4
Save and Test

Click 'OK' to close the editor, then click 'Close' to exit the properties dialog. Exit form editing mode and click the checkbox to verify that only the blank fields in your sequence are filled with 'EMPTY'.

Add a JavaScript Action to the Checkbox
Customizing the Script: You can easily adapt this script for different forms by changing the field prefix ('Weight'), the total number of fields ('14'), or the default text ('EMPTY') directly within the code.
Advanced PDF Tools

Create and Manage PDF Forms Easily with WPS Office

WPS Office provides a comprehensive suite of PDF editing tools. You can easily create interactive forms, add checkboxes, manage text fields, and process PDF documents efficiently in an intuitive interface.

  1. 1. Open PDF in WPS Office: Launch WPS Office and open your PDF document.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access interactive form controls.
  3. 3. Edit Form Elements: Click on 'Text Field', 'Check Box', or other tools to draw them onto your page, then double-click the elements to configure their properties.
Easily insert interactive text fields, checkboxes, and buttonsHighly compatible with Adobe Acrobat PDF formats and formsLightweight application with a seamless, user-friendly interfaceEdit PDF text, merge documents, and convert formats in one place
microsoft office alternative - wps office

Frequently Asked Questions

Why does the script overwrite fields that already contain data?

This happens if the script lacks a condition to check for empty values. Ensure your script includes `&& this.getField("FieldName" + i).value == ""` within the `if` statement to prevent overwriting existing data.

Can I use this script for fields that do not end in sequential numbers?

The provided `for` loop specifically targets sequentially numbered fields. If your fields have unique, non-sequential names, you will need to list them in a JavaScript array and iterate through that array instead.

How do I clear the 'EMPTY' text if I uncheck the checkbox?

You can expand the script with an `else` block or an additional condition that checks if `event.target.value == "Off"`. Inside that block, instruct the script to loop through the fields and reset them to a blank string (`""`) if their value is currently "EMPTY".