PDF Editing Issues

How to Save Multiple Checkbox Values to a Text Field in PDF

Adam DavisAdam Davis Nov 3, 2026 869 views

Question details

The user needs a JavaScript solution to collect the export values of several selected checkboxes and output them into a single text field, separated by commas or semicolons.

How to Save Multiple Checkbox Values to a Text Field in PDF Forms
Product
Adobe Acrobat / PDF Forms
Device & OS
not provided
Scenario
Creating dynamic PDF forms where checking multiple options automatically consolidates the results into a single summary text field.
Observed behavior
Needs to properly join multiple active checkbox values into one text field without overwriting the variable for each selection.
Before you start

Ensure your PDF form has all the required checkboxes and the target text field properly created and named before applying custom calculation scripts.

Solution 1Recommended

Use a JavaScript Array to Collect and Join Checkbox Values

This method pushes the export values of all actively selected checkboxes into an array, and then joins them into a single string to display in your target field.

Instead of overwriting a single variable for each checkbox, you can declare an array and check the state of each checkbox individually. If a checkbox is not 'Off' (meaning it is selected), its value is pushed to the array. Finally, the array is joined with a specific separator.

1
Open Text Field Properties

Right-click the target text field (e.g., Matrix_Test_Code) where you want the combined values to be displayed and select 'Properties'.

2
Add a Custom Calculation Script

Navigate to the 'Calculate' tab in the Properties window, select 'Custom calculation script', and click the 'Edit' button to open the JavaScript editor.

3
Insert the JavaScript Code

Enter the following script to define an array and evaluate each checkbox: var values = []; if (this.getField('ACHE_S').value !== 'Off') values.push('ACHE_S'); if (this.getField('ACHE_T').value !== 'Off') values.push('ACHE_T'); event.value = values.join(', ');

4
Apply and Test

Click 'OK' to save the script. Close the properties window and switch to 'Preview' mode. Test checking and unchecking the boxes to verify that the text field updates dynamically.

Use a JavaScript Array to Collect and Join Checkbox Values
Extending the Script: You can extend this exact pattern for the remaining checkboxes. Just copy the 'if' statement and replace the field names with the specific names of your other checkboxes.
Edit PDF Forms Easily

Manage PDF Forms and Fields with WPS Office

WPS Office provides powerful PDF editing features, allowing you to easily interact with, fill out, and manage interactive PDF forms without complex scripting requirements.

  1. 1. Open PDF in WPS: Launch WPS Office and open your interactive PDF document.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access the interactive form features.
  3. 3. Fill and Manage Fields: Interact with text fields, checkboxes, and buttons natively without worrying about underlying code errors.
  4. 4. Save and Export: Save your completed document, maintaining full compatibility with all standard PDF viewers.
Easily view and fill interactive PDF form fieldsHigh compatibility with standard PDF formats and Microsoft Office documentsLightweight application with a highly intuitive user interfaceRobust cross-platform support for Windows, Mac, iOS, and Android
microsoft office alternative - wps office

Frequently Asked Questions

Why is my text field only showing the last selected checkbox value?

This happens if you overwrite a single variable repeatedly (e.g., event.value = 'A'; event.value = 'B';). By using a JavaScript array and the .push() method, you collect all selected values and combine them at the end.

What does 'Off' mean in PDF checkbox JavaScript?

In PDF form calculations, 'Off' is the default value when a checkbox is unchecked. Checking if a field's value !== 'Off' ensures you only extract data from the boxes the user has actively checked.

Can I separate the joined values with semicolons instead of commas?

Yes. In the final line of your JavaScript code, change event.value = values.join(', '); to event.value = values.join('; '); to use a semicolon and a space as the separator.