aspose file tools*
The moose likes JSP and the fly likes Color Table Rows Based on a Field Value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Color Table Rows Based on a Field Value" Watch "Color Table Rows Based on a Field Value" New topic
Author

Color Table Rows Based on a Field Value

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1419
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
Would be better to use classes






Eric
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1419
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
Moving to JSP since it is not an HTML question.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

Where does this "value of a cell" come from?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1419
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Jan 10, 2002
Posts: 61010
    
  65

Paul Clapham wrote:You can use <c:select> for this.

Paul, of course, meant <c:choose>.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1419
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?

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Color Table Rows Based on a Field Value