PDF Editing Issues

How to Make Sales Tax Optional with a Checkbox in PDF Forms

Algirdas JasaitisAlgirdas Jasaitis Nov 2, 2026 869 views

Question details

The user needs to add a conditional checkbox to a PDF receipt form that includes or excludes a specific sales tax rate from the grand total when toggled.

How to Make Sales Tax Optional with a Checkbox in PDF Forms
Product
PDF Form Editors
Device & OS
not provided
Scenario
Creating a dynamic PDF receipt form with conditional tax calculations based on user selection.
Observed behavior
The user wants a conditional script where selecting or deselecting a checkbox recalculates the grand total dynamically.
Before you start

Ensure you know the exact field names for your 'Subtotal' field and your 'AddTax' checkbox, as JavaScript calculations in PDF forms are strictly case-sensitive.

Solution 1Recommended

Use a Custom Calculation Script in the Grand Total Field

Apply a JavaScript snippet to the Grand Total field to conditionally calculate the tax based on the checkbox state.

Instead of applying a script to the checkbox itself, the calculation should be handled directly by the Grand Total field. This ensures the total updates dynamically whenever the form fields are modified or the checkbox is toggled.

1
Open Field Properties

Right-click the Grand Total field in your PDF form editor and select 'Properties'.

2
Navigate to the Calculate Tab

In the Properties dialog box, click on the 'Calculate' tab to view calculation options.

3
Enter Custom Script

Select 'Custom calculation script' and click 'Edit'. Enter the following JavaScript code: var taxRate = 0.0725; var subtotal = Number(this.getField('Subtotal').valueAsString); var addTax = this.getField('AddTax').valueAsString; if (addTax == 'Off') event.value = subtotal; else event.value = subtotal * (1 + taxRate);

4
Verify Field Names

Ensure that 'Subtotal' and 'AddTax' in the script perfectly match the actual names of your form fields.

Use a Custom Calculation Script in the Grand Total Field
Field Formatting Required: Make sure your Subtotal field is formatted as a number so the calculation function reads the values correctly instead of treating them as plain text.
Efficient PDF Form Editing

Create and Edit Interactive PDF Forms with WPS Office

WPS PDF provides robust tools for viewing, filling, and managing interactive PDF forms. Whether you need to handle invoices, receipts, or complex dynamic documents, WPS Office offers a powerful and accessible experience.

  1. 1. Open your PDF Form: Launch WPS Office and open your PDF receipt or interactive form document.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to highlight and view all interactive fields.
  3. 3. Fill and Save: Interact with checkboxes, fill in text fields, and save your completed document effortlessly.
Easily view, fill, and interact with dynamic PDF form fields and checkboxesHighly compatible with Adobe Acrobat PDF formats and interactive elementsLightweight, fast, and features an intuitive navigation interfaceComprehensive PDF editing, annotating, and conversion tools built-in
QA img-9

Frequently Asked Questions

Why is my grand total not updating when I click the checkbox?

This typically happens if the field calculation order in the PDF is incorrect, or if the field names in your JavaScript snippet do not exactly match the actual form field names (which are case-sensitive).

Can I use a different tax rate in the custom script?

Yes, simply modify the `var taxRate = 0.0725;` line in the script to reflect your local tax rate. For example, for a 5% tax, change it to `var taxRate = 0.05;`.

Does the checkbox field itself need a calculation script?

No, the checkbox does not need its own script. The logic is entirely managed within the Grand Total field's custom calculation script, which checks the status of the checkbox to determine the final value.