How to Combine Multiple Checkbox Conditions in PDF JavaScript
Question details
The user needs a calculated PDF text field to display a specific company name when any one of three checkboxes is selected using JavaScript.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating dynamic PDF forms that require multiple conditions to trigger a text field value.
- Observed behavior
- The text field needs a custom calculation script using the OR operator to evaluate the states of multiple checkboxes.
Ensure you have your PDF form open in editing mode with the correct field names for your checkboxes and target text field clearly identified.
Use the Logical OR (||) Operator in Acrobat Custom Calculation Script
Apply a custom calculation script using the || operator to check if any of the specified checkboxes are ticked.
In PDF form JavaScript, the logical OR operator is represented by two vertical pipes (||). This allows you to evaluate multiple conditions, where the overall statement is true if at least one condition is met.
You can use a ternary operator (? :) to assign the value of the 'Company Name' field to your target text field if any checkbox is 'Yes', or leave it blank otherwise.
Right-click the target calculated text field in your PDF form and select 'Properties'.
Click on the 'Calculate' tab and select the 'Custom calculation script' radio button.
Click 'Edit' and paste the following script: event.value = (this.getField("Checkbox1").value == "Yes" || this.getField("Checkbox2").value == "Yes" || this.getField("Checkbox3").value == "Yes") ? this.getField("Company Name").valueAsString : "";
Replace 'Checkbox1', 'Checkbox2', 'Checkbox3', and 'Company Name' with the exact names of the fields in your specific PDF form. JavaScript is case-sensitive, so ensure the names match exactly.

Easily Manage and Fill PDF Forms with WPS Office
While advanced JavaScript calculation requires specialized coding during form creation, WPS Office provides a comprehensive, user-friendly PDF editor to view, fill out, and manage interactive PDF forms effortlessly.
- 1. Download and Install: Download WPS Office for free from the official website and install it on your device.
- 2. Open Your PDF Form: Launch WPS Office, click on 'Open', and select your interactive PDF form.
- 3. Fill Out the Form: Click directly into the text fields, checkboxes, or dropdown menus to input your information smoothly.
- 4. Save and Share: Once filled, click 'Save' or 'Export' to keep your data intact and share the document with others.

Frequently Asked Questions
What does the || operator do in PDF JavaScript?
The || operator represents the logical OR function. It evaluates multiple conditions and returns true if at least one of the conditions is met. In form fields, it helps trigger actions when any one of several checkboxes is selected.
Why is my custom calculation script not working in Acrobat?
Common reasons include incorrect field names (JavaScript is case-sensitive), wrong export values for checkboxes (e.g., using 'On' instead of 'Yes'), or syntax errors such as missing parentheses or quotes in the script.
How do I check the export value of a checkbox in a PDF form?
Right-click the checkbox in form editing mode, select 'Properties', and navigate to the 'Options' tab. The 'Export Value' field will show the exact string (like 'Yes' or 'On') you need to use in your JavaScript code.
Can I use the AND operator instead of OR?
Yes. If you need the text field to display the company name only when ALL checkboxes are selected, replace the logical OR operator (||) with the logical AND operator (&&) in your script.




