PDF Editing Issues

Create a Fillable PDF Form with Show and Hide Fields in Adobe Acrobat

Nimra MalikNimra Malik Nov 25, 2026 869 views

Question details

Create a fillable PDF that displays different fields, text, or images based on a user's selection.

Create a Fillable PDF Form with Show and Hide Fields in Adobe Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A form creator wants one PDF to present different layouts when a user selects an option.
Observed behavior
The selected option should determine which form elements are visible, including when a saved form is reopened.
Before you start

Open the PDF in Adobe Acrobat and make sure you can use Prepare a form and Acrobat JavaScript. Decide which fields belong to each option and test the finished form in the PDF viewers your audience will use.

Solution 1Recommended

Use a Dropdown and Acrobat JavaScript to Control Form Fields

Use this approach when each choice should show a different group of fields in the same PDF.

This example uses two choices with export values A and B. Fields beginning with LayoutA. are shown for choice A, and fields beginning with LayoutB. are shown for choice B.

Static text or images on the PDF page are not affected by field visibility. To switch them with this method, place text in read-only form fields or images in button fields.

1
Create the dropdown

Open the PDF and choose All tools > Prepare a form. Add a dropdown named LayoutChoice. In its Properties > Options, add two choices with export values A and B, and enable Commit selected value immediately.

2
Add the conditional fields

In Prepare a form, add the fields for each layout. Name the first group with the prefix LayoutA. and the second with LayoutB.; for example, LayoutA.Name and LayoutB.Name. Add any read-only text fields or button fields needed for conditional text or images.

3
Add a document-level script

Open the JavaScript tools and choose Document JavaScripts. Add a script named LayoutControl with this code: function setLayout(v) { for (var i = 0; i < this.numFields; i++) { var n = this.getNthFieldName(i); var f = this.getField(n); if (n.indexOf('LayoutA.') === 0) f.display = (v === 'A') ? display.visible : display.hidden; if (n.indexOf('LayoutB.') === 0) f.display = (v === 'B') ? display.visible : display.hidden; } } var choice = this.getField('LayoutChoice'); if (choice) setLayout(choice.value);

4
Run the script when the choice changes

Open the LayoutChoice dropdown's Properties > Validate, select Run custom validation script, and click Edit. Enter: setLayout(event.value);

5
Test and save the form

Use Preview in Prepare a form to select each dropdown choice and check its fields. Save the PDF, reopen it, and verify that the layout matches the saved choice. Repeat the test in the viewers and devices your recipients will use.

Use a Dropdown and Acrobat JavaScript to Control Form Fields
Visibility is not security: Hidden fields can still contain values and may be accessible or submitted. Acrobat JavaScript and saved form behavior also vary across viewers, especially on mobile devices.
Free Microsoft Office alternative

Work with PDFs and Office Documents in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. It supports common Microsoft Office formats for an easier transition, but it does not replace Acrobat's conditional form scripting workflow.

Open and review PDF forms alongside other documentsCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar interface for moving between document tasksFree, lightweight Office alternative
microsoft office alternative - wps office

Frequently Asked Questions

Can I show or hide ordinary page text with the field script?

Not directly. In Prepare a form, place conditional text in a read-only text field, or use a button field with an image, and include that field in the appropriate named group.

Will the selected layout remain visible after the PDF is reopened?

If the viewer saves the dropdown value and supports the document-level JavaScript, the script can restore the corresponding visibility when the file opens. Save, close, and reopen the form in each target viewer to verify this.

Will conditional fields work in a mobile PDF viewer?

Not necessarily. Some mobile viewers have limited or no Acrobat JavaScript support. Test the PDF on the intended devices and provide a simpler form if the conditional fields do not work.

Are hidden field values removed from the form?

No. Hiding a field changes its visibility but does not automatically clear its value. If values must not be submitted, explicitly clear them or design the submission process to exclude them.

Can I use PDF layers instead of form fields?

Acrobat JavaScript can control layers, but layer visibility may not be preserved automatically and viewer support varies. For many forms, grouped fields are simpler to manage and test.