"Arthur Shapiro" wrote
> "Ivo" wrote:
> >Semantically speaking, shouldn't those cells be TH rather than TD
elements?
> >That would exclude them from the coloring function, and you can style
them
> >separately with CSS.
>
> The Day names are, in fact, TH elements. They still seem to have been
> affected by the script.
My mistake. I was mixed up between x.getElementsByTagName('td') and x.cells
which also collects TH elements. The first is the standard way, but the
latter is much faster and better supported among browsers.
> But I'll klutz around as time permits - I'm sure this
> can be made to work.
Without doubt:
while ( i-- ) {
day=td[i].firstChild.nodeValue;
if ( /^\d/.test(day) && day <= now ){ td[i].bgColor = '#c63800'; }
}
The bit that reads /^\d/.test(day) is a regular expression which will
evaluate to true for strings starting with a digit and false otherwise. This
should solve the issue as long the content in the TH cells starts with
letters. I have copied your table together with the script to a temporary
testpage at
http://4umi.com/web/javascript/arthur.htm; the changes to the
HTML I made were adding the id to the table, correcting a typo at 8 December
and removing all bgcolors.
hth
--
Ivo