How to Set a PDF Field Value for Custom Drop-Down Text
Question details
The user wants to automatically display a specific value in a PDF form field when a user inputs a custom value not present in a related drop-down list.

- Product
- Device & OS
- not provided
- Scenario
- Creating or editing a fillable PDF form with dependent fields, specifically making a target field react to custom user input in a drop-down list.
- Observed behavior
- A dynamic setup is needed so that if a user types a custom value in the 'Passenger 1' drop-down that is not 'Yes', the dependent 'Passholder' field displays 'No'.
Ensure you are using a PDF editor that supports advanced form editing and JavaScript execution, and verify the exact name of your target drop-down field before proceeding.
Apply a Conditional Calculation Script via Field Properties
Use a custom JavaScript calculation script in the dependent field's properties to evaluate the text input from the drop-down list dynamically.
In fillable PDF forms, drop-down lists can be configured to allow users to type custom text. To make another field (like a Passholder status field) change its value based on this input, you can apply a short JavaScript condition.
The script checks if the drop-down's value exactly matches a predefined string (like 'Yes'). If it does, the field displays 'Yes'; if any other custom text is entered, it defaults to 'No'.
Open your PDF document in your PDF editor and navigate to the 'Form' tab to enable form editing mode.
Right-click the dependent field (e.g., the Passholder text field) and select 'Properties' from the context menu.
In the Properties dialog box, click on the 'Calculate' tab to view the calculation options.
Select the 'Custom calculation script' radio button, click 'Edit', and paste the following code: event.value = (this.getField("Passenger 1").valueAsString == "Yes") ? "Yes" : "No";
Click 'OK' to save the script, close the Properties dialog, exit form editing mode, and test the drop-down by typing a custom value.

Create Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive PDF toolkit that allows you to design fillable forms, configure drop-down lists, and manage advanced field properties with ease.
- 1. Open PDF in WPS: Launch WPS Office and open your PDF document to begin editing.
- 2. Access Form Tools: Click on the 'Form' tab on the top ribbon to reveal the interactive form toolkit.
- 3. Edit Field Properties: Double-click any form field to instantly access its properties, styling, and calculation rules.

Frequently Asked Questions
Why isn't my PDF calculation script updating the field?
This usually happens if the field name referenced in the script doesn't exactly match the actual field name in the form. Check for typos, extra spaces, and ensure the capitalization is identical. Also, ensure your PDF reader supports JavaScript.
How do I allow users to type custom text into a drop-down list?
In form editing mode, right-click the drop-down field and go to 'Properties'. Under the 'Options' tab, check the box labeled 'Allow user to enter custom text' (or similar wording, depending on your editor).
Will this JavaScript calculation work on mobile PDF viewers?
Many mobile PDF viewers and built-in browser readers do not fully support interactive JavaScript calculations. For the best experience, users should fill out the form using robust desktop software like WPS Office or Adobe Acrobat.




