Auto-Populate a Text Field from a Checkbox Export Value in PDF
Question details
The user needs to automatically display the export value of a selected checkbox inside a designated text field within a PDF form.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Editing a fillable PDF form that contains multiple checkboxes sharing the same name but featuring distinct export values. The goal is to reflect the chosen checkbox's specific value dynamically in a separate text box.
- Observed behavior
- Without a calculation script, the text field remains static and does not automatically pull or display data from the selected checkbox.
Ensure you are in the form editing mode of your PDF software and that your checkboxes share the exact same field name but have different export values configured in their properties.
Apply a Custom Calculation Script to the Text Field
You can resolve this by adding a brief JavaScript calculation script to the destination text field's properties, which will fetch the checkbox's value dynamically.
In PDF forms, interactive fields can communicate using JavaScript. By applying a custom calculation script directly to the text field, it will actively monitor the checkbox group for changes and update its own value accordingly.
Open your PDF in form editing mode. Right-click the destination text field where you want the value to appear and select 'Properties'.
In the Properties dialog box, click on the 'Calculate' tab to set up automatic calculations for this specific field.
Select 'Custom calculation script' and click the 'Edit' button. Paste the following code: event.value = this.getField("myCheckBox").value; if (this.getField("myCheckBox").value == "Off") event.value = "";
Replace "myCheckBox" in the script with the exact name of your checkbox group. Click 'OK' to save the script.
Close the Properties window, exit form editing mode, and test your form by selecting different checkboxes to ensure the text field populates accurately.

Easily Create Interactive PDF Forms with WPS Office
WPS Office offers a comprehensive PDF form builder, enabling you to effortlessly insert text fields, checkboxes, and interactive elements to streamline data collection.
- 1. Open PDF File: Launch WPS Office and open your existing PDF document or create a new blank PDF.
- 2. Access the Form Tab: Navigate to the 'Form' tab on the top toolbar to reveal interactive form element options.
- 3. Insert Form Fields: Click on 'Text Field' or 'Check Box', then click and drag on the document page to position your interactive elements.
- 4. Configure Properties: Double-click any inserted field to open its properties, where you can define field names, export values, and calculation scripts seamlessly.

Frequently Asked Questions
Why does my text field display 'Off' when nothing is selected?
In PDF forms, a checkbox that is not selected defaults to an export value of 'Off'. To prevent this from displaying, the calculation script must include an 'if' statement that specifically detects the 'Off' value and replaces it with a blank space.
Can I use this method if my checkboxes have different field names?
No. The provided script works because the checkboxes function as a single group by sharing the exact same field name. If they have different names, they act entirely independently, and a more complex script would be required to evaluate each field separately.
Where do I configure the export value for a checkbox?
You can set the export value by right-clicking the checkbox in form editing mode, selecting 'Properties', and navigating to the 'Options' tab. There, you will find the 'Export Value' input box to specify the data assigned when the box is checked.




