Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

formating a cell colour depending on the value?

Posted on 2012-03-28
5
Medium Priority
?
431 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:Gurvinder Pal Singh
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 600 total points
ID: 37780348
0
 
LVL 111

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…
Suggested Courses

971 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