How to Use a Checkbox to Fill Empty PDF Fields with Default Text
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.

- Product
- 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.
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.
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.
Open your PDF document in form editing mode, right-click the specific checkbox you want to use as a trigger, and select 'Properties'.
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.
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"; } }
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'.

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. Open PDF in WPS Office: Launch WPS Office and open your PDF document.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access interactive form controls.
- 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.

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




