• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Set Select Option Color Dynamically

 
Steve Dyke
Ranch Hand
Posts: 1716
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to figure out how to set the background color of select option dynamically using JSTL.

The following has no effect.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before you even think of using the JSTL and EL, have you figured out what HTML and CSS will give you the desired result?
 
Steve Dyke
Ranch Hand
Posts: 1716
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Before you even think of using the JSTL and EL, have you figured out what HTML and CSS will give you the desired result?


Yes and I fixed this and got it to work by changing code to:

 
Tim Cooke
Sheriff
Posts: 3290
153
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello allen, welcome to the Ranch! :)

When posting code it's best to UseCodeTags (<-- read link) to make your code nice and easy to read. I've added them for you this time, see how much better it looks?

Tim - CodeRanch Moderator
 
Steve Dyke
Ranch Hand
Posts: 1716
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
allen robin wrote:Hey,try using this code:
Put background-color on the option tag..

If you want to style each one of the option tags.. use the css attribute selector:


Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!