How to Calculate PDF Form Tax Conditionally for Tax-Exempt Users
Question details
The user needs to configure a PDF form so that sales tax is only calculated and applied if the user has not selected a tax-exempt radio button.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive invoice or fillable PDF form that automatically calculates the subtotal, sales tax, and total due based on user inputs and tax-exempt status.
- Observed behavior
- The sales tax field needs to dynamically output zero when the tax-exempt 'Yes' radio button is selected, and output the correct tax rate calculation when 'No' is selected.
Ensure you have a PDF editor that supports advanced form field properties and custom calculation scripts. Identify the exact field names for your 'Subtotal' and 'Tax-Exempt' radio buttons before applying any scripts.
Use a Custom JavaScript Calculation in the Tax Field
This method uses a simple script to check the status of the tax-exempt radio button before applying the tax rate calculation.
By applying custom JavaScript to the calculation properties of your tax field, you can easily create conditional logic. This script reads the value of the radio button and forces the tax to 0 if the user claims tax exemption.
Enter the form editing mode in your PDF editor. Right-click the field where the sales tax should be displayed and select 'Properties'.
In the Properties dialog box, click on the 'Calculate' tab to set up the field's mathematical behavior.
Select 'Custom calculation script' and click 'Edit'. Assuming your radio button is named 'TAXFREE' and your subtotal is 'SUBTOTAL', enter the following code for a 15% tax rate: if (this.getField("TAXFREE").valueAsString == "NO") event.value = Number(this.getField("SUBTOTAL").valueAsString) * 0.15; else event.value = 0;
Click 'OK' to save the script, then close the Properties window. Exit form editing mode and toggle the 'Yes/No' radio buttons to verify the tax calculates correctly.

Use Radio Button Export Values (No Script Required)
This alternative method leverages the numerical export values of radio buttons to multiply the tax, avoiding JavaScript entirely.
Create Smart, Interactive PDF Forms with WPS Office
WPS Office offers a robust built-in PDF editor that allows you to easily design interactive forms, insert form fields, and manage custom calculations for invoices and tax documents.
- 1. Open the PDF document in WPS Office: Launch WPS Office and open your existing PDF invoice or start with a blank document.
- 2. Access the Form tools: Navigate to the 'Form' tab on the top menu ribbon to reveal all interactive field tools.
- 3. Insert Form Fields: Click to add Text Fields for your amounts and Radio Buttons for the tax-exempt selection.
- 4. Configure Field Properties: Right-click any added field to access 'Properties' and establish calculation rules or custom scripts.

Frequently Asked Questions
Why isn't my PDF form calculating the tax automatically?
Your form might not update automatically if the 'Calculate' preference is disabled. Additionally, the calculation order matters; ensure the subtotal is calculated before the tax field evaluates its script.
Can I use standard mathematical formulas instead of custom JavaScript for conditional taxes?
Standard PDF calculations only allow basic functions like sum, product, and average. For conditional logic (e.g., if tax-exempt is yes, then 0), you must use either a custom calculation script or manipulate export values to multiply by zero.
How do I find the exact field name to use in my calculation script?
Right-click the specific form field and select 'Properties'. The exact field name will be listed under the 'General' tab. Ensure your script matches this name precisely, including capitalization.
What happens if a user leaves the tax-exempt radio buttons entirely blank?
If neither radio button is selected, a custom script checking for "NO" will usually evaluate as false, resulting in zero tax. To prevent this, always set the standard tax option ('No') as the default selected radio button in the field properties.




