Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Changing color on a single specific dropdown selection

New Here ,
Dec 12, 2024 Dec 12, 2024

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?

TOPICS
How to , PDF , PDF forms
742
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
2 ACCEPTED SOLUTIONS
Community Expert ,
Dec 12, 2024 Dec 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;
}
}

 

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 12, 2024 Dec 12, 2024

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

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 12, 2024 Dec 12, 2024

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

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 12, 2024 Dec 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 12, 2024 Dec 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;
}
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 12, 2024 Dec 12, 2024

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 12, 2024 Dec 12, 2024

Is there also a way to add an OR statement that will allow 2 possible selections to be black wile the remaining selections would be red?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 12, 2024 Dec 12, 2024

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 12, 2024 Dec 12, 2024

Thank you! That worked!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 12, 2024 Dec 12, 2024
LATEST

Just be aware this doesn't change just the selection you make, but all the items in the drop-down. If you open it again after making that selection you will see that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines