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

Change Text Color of an item from Drop Down Menu

Contributor ,
Nov 24, 2022 Nov 24, 2022

Hello there,

I hope you are doing well,

 

I am trying to change the color text of one item in a drop-down menu list to grey, (after selecting)

 

I used this code, but it did not work

event.target.textColor = (this.getField("best_time_to_call").valueAsString=="Please select") ? color.grey: color.transparent;

 

SaherNaji_0-1669277473492.pngexpand image

 

Thank you

TOPICS
JavaScript , PDF forms
2.4K
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
1 ACCEPTED SOLUTION
Community Expert ,
Nov 24, 2022 Nov 24, 2022

Then use this:

event.target.textColor = (event.value=="Please select") ? color.gray : color.black;

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 ,
Nov 24, 2022 Nov 24, 2022

Change it to:

event.target.textColor = (event.value=="Please select") ? color.gray : color.transparent;

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 ,
Nov 24, 2022 Nov 24, 2022

Be aware this will change the color of all the items in the drop-down, though. It's not possible to change the color of just one.

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
Contributor ,
Nov 24, 2022 Nov 24, 2022

thank you, it has turned the color to grey, but what I really need is to turn the color back to Black if any items other than (Select please) are 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 ,
Nov 24, 2022 Nov 24, 2022

Then use this:

event.target.textColor = (event.value=="Please select") ? color.gray : color.black;

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
Contributor ,
Nov 24, 2022 Nov 24, 2022

Thank you very much,

it's working perfectly !

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 ,
Nov 24, 2022 Nov 24, 2022

Run the script as a Custom Format Script like this:

 

 

(event.value !== "Please select") ? f.textColor = color.black : f.textColor = color.gray;

 

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
Contributor ,
Nov 24, 2022 Nov 24, 2022
LATEST

Hi @ls_rbls 

I tested it, it's not working

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