How to Show a Text Field When 'Other' is Selected in a PDF Drop-Down
Question details
The user wants to allow respondents to enter a custom value by revealing a hidden text field only when the 'Other' option is selected from a drop-down menu in a PDF form.

- Product
- Acrobat PDF
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where predefined drop-down options might not cover all user responses, requiring a conditional custom text input.
- Observed behavior
- A text field should remain hidden by default and automatically become visible when the user selects 'Other' from the associated drop-down menu.
Ensure you are using a PDF editing program that supports advanced form field properties and JavaScript custom calculation scripts.
Use a Custom Calculation Script in the Text Field
Add a simple JavaScript code snippet to your text field's properties to monitor the drop-down menu and toggle visibility dynamically.
To achieve this, you need a separate text field designed specifically to capture the custom value. By applying a custom calculation script to this text field, it will check the current value of your drop-down menu and show or hide itself accordingly.
Insert a drop-down menu field into your PDF form. Note its exact field name (e.g., 'Dropdown1') and ensure 'Other' is listed as one of the item export values.
Create a new text field next to the drop-down menu where you want the custom input box to appear.
Right-click the text field and open its Properties. Navigate to the 'Calculate' tab, select 'Custom calculation script', and enter the following code: event.target.display = (this.getField("Dropdown1").valueAsString == "Other") ? display.visible : display.hidden;
If your drop-down menu is not named 'Dropdown1', replace 'Dropdown1' in the script with your actual drop-down field name.

Build Smart PDF Forms with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to design interactive forms, insert drop-down menus, and manage text fields with an intuitive, user-friendly interface.
- 1. Open your PDF: Launch WPS Office and open your PDF document.
- 2. Access the Form tab: Navigate to the 'Form' tab on the top ribbon to access interactive tools.
- 3. Insert form elements: Click on 'Drop-down List' or 'Text Field' and drag to draw the elements onto your document.
- 4. Configure properties: Double-click the inserted fields to set up names, options, and visibility settings.

Frequently Asked Questions
Why isn't the text field appearing when I select 'Other'?
This usually happens if the field name in your script does not exactly match the drop-down menu's actual name, or if the value 'Other' has a typo or different casing in the drop-down's export values.
Will the text field hide again if the user selects a different option?
Yes. The provided calculation script automatically re-evaluates whenever the drop-down value changes. If a user changes their selection from 'Other' to a predefined option, the text field will be hidden again.
Does this JavaScript work in all PDF readers?
This script works perfectly in standard PDF editors like Adobe Acrobat and advanced readers. However, some basic web browser PDF viewers or default system readers may not fully support JavaScript form calculations.




