Skip to main content
New Participant
October 22, 2024
Answered

Need help with changing dropdown list fill color change

  • October 22, 2024
  • 4 replies
  • 531 views

Hi, 

I am a serious beginner at JavaScript so have just been blundering about with finding situations and copy/pasting the solutions others have posted. I can't quite get this right because I thought I could merge a few different posts together to get an adequate solution to no avail.

 

I am creating a dropdown in which I have labeled "EH, H, M, L" which need to be fill color coded as Red, Orange, Yellow, Green, respectively. My issue is with the color orange, I can't seem to figure out how to make RGB values work in this script. I'm also not sure if there is an easier script to use given my ineptitude. Below is the validation script I have been using. Thanks for the help!

 

var f = this.getField("Dropdown18");

if(event.value == "EH"){
f.textColor = color.black;
f.strokeColor = color.red;
f.fillColor = color.red}

else if(event.value == "M"){
f.textColor = color.black;
f.strokeColor = color.yellow;
f.fillColor = color.yellow}

else if(event.value == "L"){
f.textColor = color.black;
f.strokeColor = color.green;
f.fillColor = color.green}

else if(event.value == "H"){
f.textColor = color.black;
f.strokeColor = color.["RGB", 255/255, 136/255, 0/255];
f.fillColor = color.["RGB", 255/255, 136/255, 0/255]}

This topic has been closed for replies.
Correct answer Nesa Nurani

Remove color. when using RGB like this:

f.strokeColor = color.["RGB", 255/255, 136/255, 0/255];

should be:

f.strokeColor = ["RGB", 255/255, 136/255, 0/255];

 

Also, if the script is in the same dropdown where you wish to change colors, replace the first line with:

var f = event.target;

4 replies

Nesa Nurani
Nesa NuraniCorrect answer
Inspiring
October 22, 2024

Remove color. when using RGB like this:

f.strokeColor = color.["RGB", 255/255, 136/255, 0/255];

should be:

f.strokeColor = ["RGB", 255/255, 136/255, 0/255];

 

Also, if the script is in the same dropdown where you wish to change colors, replace the first line with:

var f = event.target;

kglad
Braniac
October 22, 2024

in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.



<"moved from using the community">
New Participant
October 22, 2024

Thank you

New Participant
October 22, 2024

kglad
Braniac
October 22, 2024

is this an acrobat question?

New Participant
October 22, 2024

Yes, sorry that I didn't clarify. I am attempting to do this on Adobe Acrobat Pro, Prepare a Form.