[thelist] Coloring specific table cells based on a variable

Eric Hehl eric at thaitec.com
Mon Dec 4 04:53:36 CST 2000


Hi folks,

Here's my task:  I have a site with 3 sections (let's say home, library,
programs).  I'm creating a table of contents for the site and I would like
to write javascript function which will color the table cell - which
corresponds to the current section the user is in -- with a background color
of white.  All other cells would stay the global color.

I think the general work-flow would be as follows:

<Head>
var section="home"   /*Or  'library", or "programs" */
</head>

..........
<body>
<table bg-color=#00000>
<tr>
	<td>
		JAVASCRIPT: if(section="home") {bg-color=#FFFFFF}
		<href link here>
	(/td>
</tr>
<tr>
	<td>
		JAVASCRIPT: if(seciont="library") {bg-color=#FFFFFF}
		<href link here>
	</td>
(/td>
	<td>
		JAVASCRIPT: if(sectiont="programs") {bg-color=#FFFFFF}
		<href link here>
	</td>
(/td>
</body>



Now, I'm new to javascript, so I might be off a little (this is written from
my head, not consulting all my notes, so please forgive for obvious
mistakes).  Anyhow,
I've got something similar to this coded, but it keeps returning errors.
Where have I gone wrong?

The way I'm looking at this (logic wise) is that I set a variable iin the
head of the page which describes the section.  Then a set a global color for
the table (#000000)
But when the page is being displayed, Javascript is used to determine the
section (based on the 'section' variable') and if it matches the value for
that table row, then I set a specific color. . . .

Thanks in advance,

Eric






More information about the thelist mailing list