• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 437
  • Last Modified:

formating a cell colour depending on the value?

is it possible to format the color of  a cell in a table depending on the input value in the cell? Can someone let me know how this can be done? Thank you.

A
0
aej1973
Asked:
aej1973
1 Solution
 
Gurvinder Pal SinghCommented:
var allCells = document.getElementsByTagName("td");

for ( var counter = 0; counter < allCells.length; counter++)
{
   var cell  = allCells[ counter ];
   if ( cell.innerHTML == "" )//put whatever value you want to check
   {
          cell.style.color = "red";
   }
}
0
 
Kiran SonawaneProject LeadCommented:
0
 
Ray PaseurCommented:
Please post an example of the table and show us what cells should be colored, Thanks.
0
 
YZlatCommented:
check this out

http://stackoverflow.com/questions/7986581/jquery-change-table-cell-text-color-based-on-text

as long as each cell you want to be able to modify is of class "status", you could put this code inside documjent ready function

$(document).ready(function(){  
  $('.status:contains("Paid")').css('color', 'red'); 
});
 

Open in new window

0
 
aej1973Author Commented:
Thank you for the help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now