logo
search
PDF Editing Issues

How to Create a Radio Button Discount Script in Acrobat

Khadija KhanKhadija Khan Oct 23, 2026 868 views

Question details

The user wants to write a JavaScript snippet for a radio button in an Acrobat PDF form to apply a 5% discount to a calculated Grand Total field.

How to Create a Radio Button Discount Script in Adobe Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating advanced interactive PDF forms that require custom calculation logic based on user selection (e.g., applying a pickup discount).
Observed behavior
Needs the exact JavaScript logic and setup instructions to integrate a radio button selection with an existing Grand Total calculation without breaking the calculation order.
Before you start

Ensure you have a desktop version of Adobe Acrobat Pro, as standard reader applications do not allow you to author or edit form field calculation scripts. Back up your PDF before applying custom JavaScript.

Solution 1Recommended

Apply Custom Calculation Script to the Grand Total Field

Use JavaScript within the Grand Total field's calculation properties to check the value of the radio button and apply the 5% discount accordingly.

Instead of attaching the calculation script to the radio button itself, it is best practice to place the calculation logic directly inside the Grand Total field. This ensures the total dynamically updates whenever any relevant field in the form changes.

1
Prepare the Radio Button

Name your radio button group (e.g., 'DeliveryOption') and ensure the specific 'Pickup' choice has a defined export value (e.g., 'Pickup').

2
Open Field Properties

Enter Form Editing mode. Right-click your 'Grand Total' field, select 'Properties', and navigate to the 'Calculate' tab.

3
Add Custom Script

Select the 'Custom calculation script' option and click the 'Edit' button to open the JavaScript editor.

4
Insert JavaScript Logic

Write your code to calculate the base total first. Then, add an if-statement to check the radio button: `if (this.getField('DeliveryOption').value == 'Pickup') { event.value = baseTotal * 0.95; } else { event.value = baseTotal; }`.

5
Verify Calculation Order

Exit the editor and go to 'More' > 'Field Calculation Order' in the form tools. Ensure your subtotal fields calculate before the Grand Total field to prevent delayed updates.

Apply Custom Calculation Script to the Grand Total Field
Field Calculation Order: PDF forms calculate fields in a specific sequence. If your discount total is calculating one step behind, your Grand Total field is likely placed too high in the calculation order list.

Create and Manage PDF Forms Easily with WPS Office

While Acrobat offers extensive JavaScript support for complex calculations, WPS Office provides an incredibly intuitive, lightweight PDF editor for creating forms, adding text fields, and managing interactive elements seamlessly.

  1. 1. Open Your PDF: Launch WPS Office and open your PDF document within the built-in PDF editor.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access the interactive element toolkit.
  3. 3. Add Form Fields: Click on the radio button, checkbox, or text field icons, and click on your document page to place them.
  4. 4. Edit Properties: Double-click the inserted fields to configure their names, export values, and appearance.
  5. 5. Save the Interactive Form: Save your document. The interactive elements will be preserved and functional for any user filling out the form.
Easily insert text fields, checkboxes, and radio buttons into any PDFHighly compatible with Adobe Acrobat PDF forms and standard formatsLightweight application with a fast, user-friendly interfaceCost-effective alternative for everyday PDF editing and form management
microsoft office alternative - wps office

Frequently Asked Questions

Why is my PDF Grand Total calculating one step behind?

This usually happens because of an incorrect field calculation order. In your PDF editor, check the calculation order list and move the Grand Total field to the very bottom so it calculates last, after all other fields have finished processing.

What export value should I set for my discount radio button?

You can set the export value to anything descriptive, such as 'Pickup' or 'Yes'. Your JavaScript just needs to exactly match this string when checking the field's value (e.g., `if (this.getField('Group1').value == 'Pickup')`).

Do I add the JavaScript to the radio button or the total field?

For discounts affecting a total, it is highly recommended to add the Custom Calculation Script directly to the Grand Total field rather than the radio button. This ensures the total updates correctly whenever any dependent field changes.