Since this is a JavaScript question, I assume you want this done completely client-side? We'll be happy to help, but first a couple of observations:
1) This might be easier server-side. How are you generating your pages?
2) The approach will depend on your page structure and doctype. Can you give us a skeleton sample of your HTML?
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
The Date Object would indeed come into play, but the bigger question is how he'll access the "dates" that are in his table. There needs to be a corresponding Date Object for those, or a method to access those via the DOM and move them into a Date Object, before any comparsion could be done.
That's why I pointed toward the server-side solution. My guess is that this is a dynamic, program-generated page, and as such, rather than load the page with JavaScript Date Objects to do client-side, after-the-fact date recognition, he should simply do it server-side while building the page.
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
Looks good. You can validate it against w3c.org's validators, to be sure.
Ok, the short answer is that you use CSS to style HTML elements. You could create two CSS classes, one for normal color, and one for "old" dates.
<style type="text/css">
.normal
{
color: black;
}
.old
{
color: red;
}
</style>
Something like that, to use a simple example. This goes in your HEAD portion of your document.
Then, to apply the style, add the "class" attribute to your tags:
<td class="normal>normal</td>
<td class="old">old</td>
The trick is, how to do that programmatically? Again, I suggest server-side. There is no one solution, first you have to decide what language you're going to use, and learn the basics of that language.
I suggest PHP. Daniweb has a great PHP forum.
The basic idea is that you create CSS and HTML to control how the page looks, and then you write a PHP program to output the CSS & HTML. At the time the PHP program runs (which is as soon as a user browses to the page), it can enter the dates into the table, check the dates, and add the correct "class" to the table elements.
Daniweb in fact is a big PHP program.
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37