How to Autofill PDF Text Fields from Checked Boxes via JavaScript
Question details
The user needs to automatically populate text fields with values corresponding to checked boxes across a multi-page PDF form to generate flashcards or continuous lists.

- Product
- Adobe Acrobat PDF
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where checking specific boxes aggregates the selected words sequentially into empty text fields on another page.
- Observed behavior
- The user wants a script that identifies which boxes are checked, extracts their assigned export values, and automatically writes those words into a sequence of text fields without leaving blank gaps.
Ensure that your PDF form fields follow a consistent and sequential naming convention (e.g., CK1 to CK100 for checkboxes, and text1 to text100 for text fields) before attempting to apply any automated scripts.
Use a MouseUp JavaScript Action to Collect and Push Checked Values
Apply a custom JavaScript script to a button's MouseUp event to loop through the checkboxes, collect their active export values, and populate the target text fields sequentially.
This approach uses a two-part script. First, it iterates through all sequentially numbered checkboxes. If a checkbox is selected (meaning its value is not 'Off'), its designated export value is saved into an array. A second loop then takes that array of saved words and pushes them into the sequential text fields, ensuring there are no empty gaps between the populated words.
Open your PDF in Form Editing mode. Ensure your checkboxes are named sequentially (e.g., 'CK1', 'CK2'). Open the Properties for each checkbox, navigate to the Options tab, and set the 'Export Value' to the specific word you want transferred.
Create sequentially named text fields (e.g., 'text1', 'text2') on the destination pages where you want the collected words to appear.
Insert a 'Button' form field onto your document. Right-click the button and select 'Properties'. Go to the 'Actions' tab, select 'Mouse Up' as the trigger, and choose 'Run a JavaScript' as the action.
Click 'Add' and paste the following script into the editor: var words=[]; for (var i=1; i<=100; i++) { var v=this.getField('CK'+i).valueAsString; if (v!='Off') words.push(v); } for (var i=1; i<=100; i++) { var f=this.getField('text'+i); f.value=(i<=words.length)?words[i-1]:''; }.
Click 'OK' to close the script editor, exit Form Editing mode, and save your PDF. Test the form by checking a few boxes and clicking the button to verify the text fields autofill correctly.

Edit and Fill PDF Forms Easily with WPS Office
While advanced JavaScript configuration can be complex, WPS Office provides an intuitive PDF editor that makes interacting with, filling, and managing PDF forms incredibly straightforward across all your devices.
- 1. Open Your PDF: Launch WPS Office and open your interactive PDF document using the built-in PDF viewer and editor.
- 2. Highlight Fillable Fields: Navigate to the Form tab and enable field highlighting to make all interactive checkboxes, buttons, and text fields easily identifiable on the page.
- 3. Fill and Save: Click directly into the checkboxes to select your items, type into any necessary text fields, and click 'Save' to easily preserve your form inputs.

Frequently Asked Questions
Why are my text fields showing 'Off' instead of the intended words?
This happens when the 'Export Value' for the checkbox has not been correctly set. By default, unchecked boxes return 'Off' and checked boxes return 'Yes'. You must change the Export Value in the checkbox properties to the specific word you want to copy over.
Can I automatically autofill the text fields without requiring a separate button click?
Yes. Instead of using a button, you can place a similar custom calculation script directly in the properties of the destination text fields. However, having a large number of calculation fields constantly looping as you check boxes can significantly slow down PDF performance.
Does this JavaScript autofill method work on mobile PDF readers?
Most built-in mobile PDF viewers and standard web browsers have limited or zero support for Adobe Acrobat JavaScript. For scripts to execute correctly, users generally need to fill out the form using a dedicated desktop PDF application.
How does the script ensure the words appear in order with no blank spaces?
The script specifically filters out any empty or 'Off' values and only pushes active checkbox values into a temporary array. It then populates the text boxes starting from 'text1' using the collected array items, which inherently prevents any blank gaps between the populated words.




