Solved

formating a cell colour depending on the value?

Posted on 2012-03-28
5
385 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 109

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

810 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