Combo box option coloring

Combo box option coloring


I have a combo box with several options. I have been asked to change the color of one of the options to red and leave the other options black.

This is normally an easy task in HTML, but I cannot find a method to acheive this in service studio. I appreciate any help you can provide.

Hi James,

Assuming you have a style defined for the backcolor of your item in your stylesheet (or inline) like this:
  <STYLE type="text/css">{background-color:red; color:white}

and if you know the index of your option (say it is the second item of the list), then you just need to name your combo widget (say ddlTest) and then add an expression, after your dropdown, with property Escape set to false with the following expression:

"<script type=""text/javascript"">
 document.getElementById(""" + ddlTest.Id + """).options[1].className = ""red"";

(I didn't tested the syntax in Service Studio)

Notice the [1] - it is the second item of your list (starts with 0)
If you don't know the position in the list you can use a snippet of javascript to get the index by value.

Let me know if this is not enough for you to continue.

Hi Gonçalo,

This worked perfectly, thank you for your assistance.