PDF Editing Issues

Change PDF Text and Background Color Based on Two Acrobat Drop-Downs

John WilsonJohn Wilson Nov 19, 2026 869 views

Question details

Configure a PDF text field to show a label and background color determined by two drop-down selections.

Change a PDF Text Field and Color Based on Two Acrobat Drop-Downs
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form has two drop-down fields and many possible combinations, each requiring a different result in a text field.
Observed behavior
The target field should display the label and background color associated with the selected combination.
Before you start

Open the PDF in Adobe Acrobat and choose All tools > Prepare a form. Check the exact names and export values of both drop-down fields and the name of the target text field.

Solution 1Recommended

Use an Acrobat calculation script with a lookup table

Use this approach when many drop-down combinations must control one text field’s label and background color.

The example uses drop-down field names Dropdown1 and Dropdown2 and sample export values A, B, 1, and 2. Replace them with your actual field names and values, and add a lookup entry for each combination you need.

1
Open the target field properties

In Acrobat, choose All tools > Prepare a form, then double-click the target text field, such as Text100.

2
Add a custom calculation script

Open the Calculate tab, select Custom calculation script, and click Edit. Enter the following script, then click OK: var first = this.getField("Dropdown1").valueAsString; var second = this.getField("Dropdown2").valueAsString; var results = { "A": { "1": {label: "A1 Very High", fill: ["RGB", 1, 0, 0]}, "2": {label: "A2 High", fill: ["RGB", 1, 0.6, 0]} }, "B": { "1": {label: "B1 Medium", fill: ["RGB", 1, 1, 0]} } }; var result = results[first] && results[first][second]; if (result) { event.value = result.label; event.target.fillColor = result.fill; } else { event.value = ""; event.target.fillColor = ["T"]; }

3
Set drop-downs to commit immediately

In Prepare a form, double-click each drop-down, open its Options tab, and select Commit selected value immediately. Confirm that the item export values match the keys in your script.

4
Test each combination

Click Preview in Prepare a form and select combinations from both drop-downs. Confirm the target field displays the intended label and color; combinations missing from the table will clear the field and make its background transparent.

Use an Acrobat calculation script with a lookup table
Add more combinations: Add entries under each first drop-down value in the results table. RGB color components range from 0 to 1. Acrobat JavaScript execution depends on the PDF viewer and its settings, so test the form in the viewer your recipients will use.
Free Microsoft Office alternative

Work with PDFs and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its format compatibility helps make moving between office suites straightforward. Use Acrobat to configure and test the JavaScript-driven form described above.

View PDFs and use PDF editing tools in WPS OfficeOpen and edit Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXWork in a familiar interface with a lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

How do I find a drop-down field’s export values?

In Acrobat, open All tools > Prepare a form, double-click the drop-down, and check the items and their export values on the Options tab. Use those values as keys in the lookup table.

Why doesn’t the text field update when I select an option?

In each drop-down’s Properties > Options tab, enable Commit selected value immediately. Also check that the field names and export values match the script and that form calculations and JavaScript are enabled in the viewer.

What happens when a combination is not in the lookup table?

In the example script, an unmatched combination clears the text field and sets its background to transparent. Add the missing combination to the results table to display a label and color instead.

Will the calculation work in every PDF viewer?

Not necessarily. PDF viewers differ in their support for Acrobat JavaScript and may restrict scripts. Test the saved form in the viewer recipients will use.