• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Color Table Rows Based on a Field Value

 
Steve Dyke
Ranch Hand
Posts: 1621
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using JSTL to build a table on my HTML page. How can I use the value of a field to set the back ground color of the row as the table is built?
This is part of my HTML code.

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would be better to use classes






Eric
 
Steve Dyke
Ranch Hand
Posts: 1621
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Pascarello wrote:Would be better to use classes





How do I make this part of my HTML code and make it dynamic assign these classes based on the value of a cell?

Eric
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to JSP since it is not an HTML question.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where does this "value of a cell" come from?
 
Steve Dyke
Ranch Hand
Posts: 1621
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Where does this "value of a cell" come from?


the last element value in each item(it will be a 1, 2 or 3)
 
Paul Clapham
Sheriff
Posts: 21117
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use that value to compute the name of the style (urgent or whatever) and put it into a variable. You can use <c:select> for this. Then assign that style to your <tr> element.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:You can use <c:select> for this.

Paul, of course, meant <c:choose>.
 
Steve Dyke
Ranch Hand
Posts: 1621
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Use that value to compute the name of the style (urgent or whatever) and put it into a variable. You can use <c:select> for this. Then assign that style to your <tr> element.


It is probably not the best way to go but I got some javascript to work on coloring the rows dynamically. How can I add my colors to my CSS and call them from my javascript?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic