• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to change color in the options using html:options

 
Senthil Mahalingam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right now my code is like this ,


<html:select property="stdCode" value="" style="width=99%;">

<option value="">-- Choose an Option --</option>

<html:options collection="lspproval" property="code" labelProperty="name"/>

</html:select>


Just populating the dropdown using the collection.

Now i want to apply a red color for a particular option value.

( Assume the values in the list value is USA,Brazil,Italy now i have to apply green color to the USA option).

Any help ?


 
Richard Golebiowski
Ranch Hand
Posts: 213
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this belongs in the Struts forum.

Anyway, if you look at the generated HTML you will see a series of option tags. So what you need to do is set the background color for the desired option tag. You could do this by applying a style based on the tag id.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.

Also, please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.

Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic