Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to make the choices red and green in a select box variable

Nihar2
Tera Contributor

I a select box there are 2 variables ie: red, green

 

choice: red - should have the background color red

choice: green- should have the background color green

 

I attach the picture of that variable. Please help me to do this.

8 REPLIES 8

Aman Kumar S
Kilo Patron

Hi @Nihar2 

You can try below script for the same:

 g_form.getOption("fieldname", "option_value").style.color = "color value";

 

 

Best Regards
Aman Kumar

This code is not working for me.

 

g_form.getOption("testcolors", "green").style.backgroundColor = "green";
g_form.getOption("testcolors", "red").style.color = "#ff0000";

Hi @Nihar2,

 

Kindly try this community post Background Color on a choice list

Note: getControl doesn't work in portal

Best Regards
Aman Kumar