How to Show Text Based on Selected Checkboxes in a PDF Form
Question details
The user wants to display specific explanatory text lines when corresponding checkboxes are selected in a PDF form, avoiding the creation of numerous individual text boxes.

- Product
- Adobe Acrobat PDF
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form that requires dynamic explanatory text based on multiple user checkbox selections.
- Observed behavior
- The goal state is to consolidate the dynamic text into a single multiline text box using a custom calculation script to keep the document concise and easy to manage.
Ensure you are using a PDF editor with advanced form editing and JavaScript support enabled. Identify and note down the exact field names of all the checkboxes you plan to link to the text field before writing the script.
Use a Custom Calculation Script in a Multiline Text Field
Instead of creating a separate text box for every checkbox, use JavaScript to dynamically populate a single multiline text field based on which checkboxes are currently checked.
This method involves applying a custom calculation script directly to a single multiline text field. The script evaluates the state of each checkbox in the form and appends the relevant explanatory line to a string variable, which is then displayed in the text box.
Add your checkboxes to the PDF form. Open their properties and assign them unique names (e.g., 'CheckBox1', 'CheckBox2'). Ensure their export values are set properly (typically 'Yes' or 'On').
Insert a Text Field where the explanatory text should appear. Open its Properties, navigate to the 'Options' tab, and check the 'Multi-line' box so the text can wrap and display across several lines.
In the Text Field properties, go to the 'Calculate' tab. Select the 'Custom calculation script' option and click the 'Edit' button to open the JavaScript editor.
Input a script to check the checkbox values and build the text output. For example: var s = ""; if (this.getField("CheckBox1").valueAsString != "Off") s += "- Text for checkbox 1\n"; if (this.getField("CheckBox2").valueAsString != "Off") s += "- Text for checkbox 2\n"; event.value = s;
Close the JavaScript editor and exit form editing mode. Click the checkboxes in your document to verify that the multiline text field updates dynamically with the correct lines.

Create and Manage Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive suite of PDF tools, allowing you to easily add text fields, checkboxes, and interactive elements to your documents. It serves as a highly efficient alternative to heavier PDF software.
- 1. Open your PDF Document: Launch WPS Office and open the PDF file you wish to turn into an interactive form.
- 2. Navigate to Form Tools: Click on the 'Form' tab in the top ribbon menu to access the interactive form controls.
- 3. Insert Form Elements: Select 'Text Field' or 'Check Box' from the toolbar and click anywhere on the document to place the element.
- 4. Edit Element Properties: Double-click the inserted field to modify its properties, such as field name, appearance, and multi-line text options.

Frequently Asked Questions
Why is my multiline text field not showing text on different lines?
Ensure you have checked the 'Multi-line' option in the text field's properties. Additionally, verify that your calculation script uses the newline character '\n' to separate each text entry.
Can I hide the text field entirely if no checkboxes are selected?
Yes. The script provided sets the variable to an empty string ('""') by default. If no checkboxes are checked, the text box will naturally appear blank. You can also write additional JavaScript to change the field's display property to 'hidden' if preferred.
What does 'valueAsString != "Off"' mean in the PDF script?
In PDF form JavaScript, an unchecked checkbox typically returns a value of 'Off'. This condition checks if the checkbox is currently selected (meaning its value is something other than 'Off', usually 'Yes' or 'On') before appending the corresponding text.
Do calculation scripts work on mobile PDF readers?
Many default mobile PDF viewers and web browsers do not fully support JavaScript or custom calculation scripts. For the best interactive experience and proper form functioning, users should fill out the form using robust desktop PDF applications.




