Skip to main content
Participant
December 12, 2024
Answered

Changing color on a single specific dropdown selection

  • December 12, 2024
  • 8 replies
  • 940 views

Hello,

 

I am new to this and working on trying to change the color and font of only ONE specific dropdown selection out of many multiple within that dropdown list. Is there a way of doing this without having to select each and every selection item I have in the code? 

I have set the primary color of the dropdown selections to RED, but if  the user selects NONE SELECTED, I want this to show as a Bold Black color style.

Is this possible?

This topic has been closed for replies.
Correct answer try67

if (event.changeEx=="NONE SELECTED" || event.changeEx=="Something else")

8 replies

PDF Automation Station
Community Expert
Community Expert
December 12, 2024

Select "Commit selected value immediately" in the options tab of the field properties, then enter the following custom keystroke script:

 

if(!event.willCommit)
{
if(event.changeEx=="NONE SELECTED")
{
event.target.textFont="Helvetica-Bold";
event.target.textColor=color.black;
}
else
{
event.target.textFont="Helvetica";
event.target.textColor=color.red;
}
}

 

B777232ERAuthor
Participant
December 12, 2024

This is EXACTLY what I needed, thank you so much!

PDF Automation Station
Community Expert
Community Expert
December 12, 2024

Do you mean the color is different for one selection when viewing them all in the expanded dropdown, or do you mean you want one of them different once it is selected?

Thom Parker
Community Expert
Community Expert
December 12, 2024

You can't. Not an option. Cool idea though!

 

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