PDF Editing Issues

How to Display a Conditional Sum When a PDF Checkbox Is Selected

Algirdas JasaitisAlgirdas Jasaitis Nov 3, 2026 869 views

Question details

The user needs to calculate and display the sum of several numeric fields in a PDF form strictly when a specific check box is ticked.

How to Display a Conditional Sum When a PDF Checkbox Is Selected
Product
PDF Editors
Device & OS
not provided
Scenario
Designing an interactive PDF form that requires dynamic math calculations dependent on a user's checkbox selection.
Observed behavior
The total field needs to remain blank or zero until the user explicitly selects a checkbox to trigger the addition of target numeric fields.
Before you start

Verify the exact field names for your checkbox and numeric fields, and ensure you are using a PDF editor with advanced form properties that support custom JavaScript.

Solution 1Recommended

Use a Custom Calculation Script in Form Properties

Add a JavaScript condition to the total field to check the state of the checkbox before executing the sum calculation.

Interactive PDF forms use JavaScript to handle conditional logic. By checking the export value of the checkbox (which defaults to 'Off' when unchecked), you can instruct the total text field to either sum up specific fields or return a blank value.

1
Open Field Properties

Open your PDF form in editing mode. Right-click the 'Total' text field where you want the sum to appear and select 'Properties'.

2
Navigate to the Calculate Tab

In the Properties dialog box, click on the 'Calculate' tab at the top and select the 'Custom calculation script' option.

3
Enter the JavaScript Code

Click the 'Edit' button and enter a script evaluating the checkbox. Example: `if (this.getField("Check Box 1").value !== "Off") { event.value = this.getField("Store 1").value + this.getField("Store 2").value; } else { event.value = ""; }`

4
Save and Test

Replace the placeholder field names with your actual field names, click 'OK' to save the script, and close the properties window. Toggle the checkbox to verify the calculation works.

Use a Custom Calculation Script in Form Properties
Field Naming Rule: Ensure the field names in your script perfectly match the names of the text fields on your PDF, as JavaScript is case-sensitive.
Seamless PDF Form Management

Create and Edit Interactive PDF Forms with WPS PDF

WPS Office provides robust PDF editing capabilities, empowering you to effortlessly insert text fields, checkboxes, and apply advanced calculations to make your PDF forms dynamic.

  1. 1. Open the PDF File: Launch WPS Office, switch to the PDF module, and open your form document.
  2. 2. Access Interactive Form Tools: Navigate to the 'Form' tab on the top ribbon to view available interactive elements.
  3. 3. Insert Form Fields: Use the 'Text Field' and 'Check Box' options to build your layout and assign names to each field.
  4. 4. Configure Field Properties: Double-click your target result field to access properties, navigate to the Calculate settings, and define your sum or conditional rules.
Easily add and format interactive form controls like text fields and checkboxes.Fully compatible with standard PDF form scripts and Adobe Acrobat formats.Lightweight suite with robust PDF viewing, creating, and editing tools.Cross-platform support for seamless form filling on Windows, Mac, and mobile devices.
microsoft office alternative - wps office

Frequently Asked Questions

Can I calculate a sum in a PDF without using JavaScript?

Yes, for a basic sum, you can use the built-in 'Value is the sum of the following fields' option in the Calculate tab of the field properties. However, making it conditional (triggering only when a checkbox is selected) strictly requires a custom JavaScript calculation.

What is the default export value of a PDF checkbox?

By default, a checked box returns an export value of 'Yes', and an unchecked box returns 'Off'. You can verify or customize the 'Yes' value by checking the 'Options' tab in the checkbox properties.

Why is my PDF form calculation not updating automatically?

This usually happens due to calculation order issues or software preferences. Ensure that 'Calculate fields automatically' is enabled in your PDF editor's preference settings, and check that the target fields are ordered correctly in the form field panel.