How to Submit a PDF Form to Different Email Addresses Based on a Radio Button
Question details
A PDF form script intended to route submissions to different email addresses based on a radio button choice consistently sends the email to the first address instead.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Developing a fillable PDF form that uses JavaScript to dynamically route form submissions to specific email recipients depending on the user's selected radio button.
- Observed behavior
- The JavaScript ignores the selected radio button and defaults to submitting the form to the first email address because of assignment operator errors and incorrect form submission parameters.
Ensure you are testing your PDF form in a dedicated desktop PDF editor, as many web browsers and mobile PDF viewers do not fully support JavaScript execution or email submission actions.
Correct the JavaScript Operators and Submit Parameters
Fix syntax errors in your JavaScript code by replacing assignment operators with comparison operators and correctly invoking the submitForm method.
This issue typically occurs when a script uses a single equals sign (=), which assigns a value, instead of double (==) or strict (===) equals signs to compare the radio button's value. Additionally, because submitForm does not return a field value, assigning its output to an event value breaks the logic.
Open your PDF form in "Prepare Form" mode, right-click your submit button, select "Properties", and navigate to the "Actions" tab to edit your "Run a JavaScript" action.
Locate your `if` statements and change any assignment operators (e.g., `if (radioValue = 1)`) to comparison operators (e.g., `if (radioValue == 1)`).
Ensure you are not assigning the result of the submit action to `event.value`. Delete any syntax like `event.value = this.submitForm(...)`.
Execute the submission directly using `this.submitForm({cURL: "mailto:yourname@example.com", cSubmitAs: "PDF"});` customized for each respective radio button condition.

Create and Fill PDF Forms Easily with WPS Office
If you are struggling with complex PDF form scripts, use WPS Office to create, edit, and fill interactive PDF forms efficiently. It provides a highly compatible and intuitive interface for managing form fields like radio buttons, checkboxes, and text boxes.
- 1. Open your document: Download and launch WPS Office, then open your existing PDF document.
- 2. Access form tools: Navigate to the 'Form' tab on the top menu bar to access the interactive form editing tools.
- 3. Insert form fields: Use the toolbar to seamlessly insert radio buttons, text fields, checkboxes, and push buttons.
- 4. Configure properties: Double-click any form field to quickly configure its properties, export values, and appearance settings.

Frequently Asked Questions
Why doesn't the submitForm JavaScript work in Chrome or Edge?
Built-in browser PDF viewers typically disable or have very limited support for advanced PDF JavaScript, including the submitForm method and mailto: protocols, due to security constraints. Users must open the form in a standalone desktop PDF reader.
What is the difference between single (=) and double (==) equals signs in PDF JavaScript?
A single equals sign (=) is an assignment operator that forces a variable to hold a specific value. A double equals sign (==) is a comparison operator used in "if" statements to evaluate whether two values are the same without altering them.
How do I get the selected value of a radio button group in PDF JavaScript?
You can retrieve the currently selected value of a radio button group using the script: var rbValue = this.getField("YourRadioButtonGroupName").value; Ensure all radio buttons in the group share the same name but possess unique export values.




