PDF Editing Issues

How to Use PDF JavaScript to Set Approved Status with Radio Buttons

Aamir Naveed AkramAamir Naveed Akram Nov 3, 2026 869 views

Question details

The user needs to capture the value of a selected radio button in an interactive PDF form using JavaScript to set a variable for email processing and properly validate required radio buttons.

How to Use PDF JavaScript to Set Approved Status with Radio Buttons
Product
PDF Form
Device & OS
not provided
Scenario
Creating an interactive PDF form where a supervisor selects an 'Approved' or 'Disapproved' radio button, which dynamically updates a variable used for an email subject and body.
Observed behavior
The user requires the correct JavaScript logic to retrieve the radio button's state and correctly validate required fields, specifically handling the default 'Off' value of unselected radio buttons.
Before you start

Ensure your PDF editor supports JavaScript for form fields, and verify that your mutually exclusive radio buttons share the exact same field name before applying the script.

Solution 1Recommended

Use JavaScript to Read Radio Button Values

Extract the value from the radio button group and assign it to an approval variable for email processing.

To properly read a radio button selection, you can check the value of the radio group. If the group shares a single name, it acts as one field. Depending on which button is selected, it returns that specific button's export value.

1
Access Form Field Properties

Open your interactive PDF form in edit mode and right-click the button or field that will trigger the email script. Select 'Properties'.

2
Add a JavaScript Action

Navigate to the 'Actions' tab, select 'Run a JavaScript' from the action list, and click 'Add'.

3
Write the Conditional Statement

In the JavaScript editor, input the following logic to check the radio button (assuming the field name is 'Radio'): if (this.getField("Radio").value == "Yes") { S_auth = "Approved"; } else { S_auth = "Disapproved"; }

4
Build the Email Content

Use the newly populated S_auth variable to build your email subject and body string before passing it to the mail submission function.

Use JavaScript to Read Radio Button Values
Variable Assignment: You can assign the result to the existing variable without redeclaring it. This ensures that the mutually exclusive choices correctly dictate the workflow.
Easily Edit PDF Forms

Manage and Edit PDF Forms with WPS Office

WPS PDF provides robust, easy-to-use tools to create interactive PDF forms, insert radio buttons, text fields, and manage form properties seamlessly. You can easily build professional documents and collect responses.

  1. 1. Open your PDF Document: Launch WPS Office and open your PDF file using the WPS PDF editor.
  2. 2. Navigate to Form Tools: Click on the 'Form' tab in the top ribbon to access the interactive form creation tools.
  3. 3. Insert Radio Buttons: Select the 'Radio Button' icon and click on the document page to place mutually exclusive options.
  4. 4. Configure Properties: Double-click the inserted radio button to configure its name, export values, and required status.
Add interactive form fields like radio buttons, checkboxes, and text boxes effortlessly.Highly compatible with Adobe Acrobat PDF forms and standard form interactions.Lightweight, fast, and available across multiple operating systems.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my required radio button validation fail?

When validating radio buttons in PDF JavaScript, an unselected radio button group returns the string value 'Off'. Ensure your script checks for f.value == 'Off' rather than an empty string.

Can I use the radio button value directly in an email subject?

Yes. Once you assign the radio button's value to a variable based on the selection, you can concatenate this variable into a mailto link or use it in an email submission script string.

Are mutually exclusive radio buttons treated as one field?

Yes, mutually exclusive radio buttons must share the exact same field name but have different export values (e.g., 'Yes' and 'No'). The JavaScript getField method references the group as a single entity.