View Full Version : coloring html table cell based on cell value

06-28-2007, 10:27 AM

hello friends, i have problem here, please help me.
i have a jsp page in that jsp page i am displaying the data retrived from the database(mysql). i am displaying data in table format.
noe the problem is i want to color table cell based on cell value. that is if table cell consists value say "met" then i want to color that table cell in green color. like this for other cell.
first i want check the value and then select bgcolor for that cell accordingl .

i need working code for this . or sample code for checking condition in <td> tag.

please help me.its urgent.

thanks and regards

06-28-2007, 10:51 AM
I'd suggest that when you place the value in the cell from the database, you also assign a class (maybe with the same name) at the same time so you'd end up with:

<td class="met"><p>Met</p></td>
You can then style the background for that in CSS:

td.met {background-color:#FF0000;}