Solved

formating a cell colour depending on the value?

Posted on 2012-03-28
5
375 Views
Last Modified: 2012-04-02
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
Comment
Question by:aej1973
5 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 37780322
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
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 150 total points
ID: 37780348
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37781212
Please post an example of the table and show us what cells should be colored, Thanks.
0
 
LVL 35

Expert Comment

by:YZlat
ID: 37781509
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
 

Author Comment

by:aej1973
ID: 37798436
Thank you for the help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Form Processing in PHP 11 30
unset shopping cart session 15 29
What is the best PDF generator to use? 1 24
Bootstrap collapse causes odd behavior with php loop 7 20
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now