How to Use a PDF Dropdown Value as the Email Subject with JavaScript
Question details
The user needs to extract a selected value from a dropdown field in an interactive PDF form and automatically use it as the subject line of the email generated upon form submission.

- Product
- PDF Form Editor
- Device & OS
- not provided
- Scenario
- Creating or modifying an interactive PDF form that requires a dynamic, user-selected email subject when the form is submitted.
- Observed behavior
- The goal is to automatically populate the email's subject line with the dropdown selection using a custom JavaScript action attached to a submit button.
Ensure you are using a PDF editor that supports advanced JavaScript actions for forms (such as Adobe Acrobat) and that your PDF contains both a named dropdown field and a submit button.
Use JavaScript to Concatenate the Dropdown Value in submitForm()
Configure a custom JavaScript action on your submit button to extract the dropdown's value and append it to the mailto URL.
When designing interactive PDF forms, the submitForm() method allows you to define submission properties, including the destination URL. By capturing the valueAsString property of the dropdown field, you can dynamically construct a mailto link that populates the email's subject line.
Open your PDF form in edit mode, right-click the submit button, and select 'Properties'.
Navigate to the 'Actions' tab. Select 'Run a JavaScript' from the 'Select Action' dropdown menu, then click 'Add'.
In the JavaScript editor, input the following code: this.submitForm({cURL: "mailto:example@example.com?subject=" + this.getField("Dropdown").valueAsString, cSubmitAs: "PDF"});
Replace 'example@example.com' with your destination email and 'Dropdown' with the exact field name of your dropdown menu. Click 'OK' and save your PDF document.

Fill and Manage PDF Forms Seamlessly with WPS Office
WPS Office provides a comprehensive PDF toolkit that allows you to easily open, fill out, and interact with complex PDF forms containing JavaScript, while offering cross-platform convenience.
- 1. Install WPS Office: Download and install WPS Office, then launch the WPS PDF module.
- 2. Open Your PDF Form: Click 'Open PDF' to load your interactive form document.
- 3. Fill and Submit: Select your desired dropdown values and click the submit button. WPS PDF will handle the form submission smoothly.

Frequently Asked Questions
Why is the dropdown value not appearing in my email subject?
This usually happens if the field name referenced in your JavaScript does not perfectly match the actual dropdown field name. PDF form field names are case-sensitive. Verify that the name inside this.getField("Name") exactly matches your dropdown's name.
How do I add multiple field values to the email subject?
You can concatenate multiple field values using the '+' operator in JavaScript. For example: "...subject=" + this.getField("Field1").valueAsString + " - " + this.getField("Field2").valueAsString.
Can I send the PDF form data as FDF instead of the whole PDF?
Yes. In the submitForm() method parameters, change cSubmitAs: "PDF" to cSubmitAs: "FDF". This will extract only the form field data, making the email attachment much smaller and easier to process.




