Skip to main content
Participant
July 17, 2025
Question

Dropdoown list with color that stay after click out of it

  • July 17, 2025
  • 1 reply
  • 180 views

I want to make a dropdown list
i need it with color
means i choose e.g. green the field will be green including the letters
and i want that the field stays in that color of my choice

best would be if the colors use RGB code

and i want the color i choose on another page of my pdf too. so the field should change the color on the hole dokument.
i use adobe acrobat pro 2020
i know i need to use a javascript and i tried something already BUT all didint work out.

1 reply

creative explorer
Community Expert
Community Expert
August 10, 2025

@ChocoDoodle The easiest way to achieve this is to add a JavaScript to the dropdown list itself and then a document-level JavaScript to apply the changes across the entire PDF. First, create your dropdown list. In Adobe Acrobat Pro, go to Tools > Prepare Form. Select the dropdown list tool and place it on your document. Double-click the field to open its properties, then navigate to the Options tab. Add the items you want in your dropdown list, such as "Green", "Red", "Blue", etc. .

 

Next, go to the Actions tab in the dropdown properties. For the Select Trigger option, choose Mouse Up, and for the Select Action option, choose Run a JavaScript. Click the Add button and paste the following code, which you will need to customize for your specific color choices and field names. This script will change the color of the dropdown list itself.

 

// Get the dropdown field object
var dropdownField = event.target;

// Get the value of the selected item
var selectedValue = dropdownField.value;

// Define your color codes
var greenColor = [ "RGB", 0, 1, 0 ]; // Green
var redColor = [ "RGB", 1, 0, 0 ]; // Red
var blueColor = [ "RGB", 0, 0, 1 ]; // Blue

// Set the field color based on the selected value
if (selectedValue === "Green") {
dropdownField.fillColor = greenColor;
} else if (selectedValue === "Red") {
dropdownField.fillColor = redColor;
} else if (selectedValue === "Blue") {
dropdownField.fillColor = blueColor;
} else {
// Default color if none of the above are chosen
dropdownField.fillColor = [ "T" ]; // Transparent
}

 

m
Nesa Nurani
Community Expert
Community Expert
August 10, 2025

@creative explorer It will not work correctly as Mouse UP, you will have a delay.

@ChocoDoodle What do you mean you wish to color both background and letters, then you won't be able to see letters?

When you say across PDF, you mean other dropdown fields?

To see the background colors, you will have to uncheck 'Show border hover color for fields' in preferences.