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

Change Text Color of an item from Drop Down Menu

Participant ,
Nov 24, 2022 Nov 24, 2022

Copy link to clipboard

Copied

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.png

 

Thank you

TOPICS
JavaScript , PDF forms

Views

951

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Nov 24, 2022 Nov 24, 2022

Then use this:

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

Votes

Translate

Translate
Community Expert ,
Nov 24, 2022 Nov 24, 2022

Copy link to clipboard

Copied

Change it to:

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Then use this:

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Thank you very much,

it's working perfectly !

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Run the script as a Custom Format Script like this:

 

 

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

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Hi @ls_rbls 

I tested it, it's not working

Votes

Translate

Translate

Report

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