Skip to main content
Participant
November 8, 2022
Question

Custom formatting for drop down menu color change.

  • November 8, 2022
  • 1 reply
  • 2695 views

Hi, 

Being a beginner at Javascript and have been looking and searching for the right code. 

I really hope that you can help me.

 

I have created a fillable PDF with a dropdown menus. The dropdowns have 3 options and want each option to result in a color.

This is the script I currently have been working on i'm able to get the color to change for "Complete" but not for "In Progress" or "Not Started"

 

if (event.value=="Complete")

event.target.fillColor = color.green;

else if (event.value=="In_Progress")

event.target.fillColor = color.yellow;

else if (event.value=="Not­_Started")

event.target.fillColor = color.Red;

event.target.fillColor = color.transparent;

 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
November 8, 2022

-It's "color.red", not "color.Red".

-"color.yellow" is a CMYK color, not an RGB one. Try it with an RGB code, instead.

Participant
November 9, 2022

I changed it to "color.red" still did not work 

Thom Parker
Community Expert
Community Expert
November 9, 2022

The last line overrides the others. Looks like you are missing an "else"

And the "Commit value immediately" option should be checked. 

 

 

if (event.value=="Complete")
   event.target.fillColor = color.green;
else if (event.value=="In_Progress")
   event.target.fillColor = color.yellow;
else if (event.value=="Not­_Started")
   event.target.fillColor = color.Red;
else
   event.target.fillColor = color.transparent;

 

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often