Solved

formating a cell colour depending on the value?

Posted on 2012-03-28
5
398 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 110

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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…
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 look for a specific file type in a local or remote server directory using PHP.

680 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