Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a variable??

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
I'm fairly new to HTML so ber with me please... I've got a table and each individual cell has color, (but all of the colors are the same). occasionally I want to change the color up but I don't want to have to go through and change every one of the color tags. There's hundreds...

I swore I saw something about using variables for this sort of thing but i couldn't even find any documentation. Can anyone help me out??

Thanks a lot!


Cyprus
 
I do know a solution, but it's a lot of work, but only once:

Give each <td>-tag an id like so: <td id=&quot;cell1&quot;> and the next <td id=&quot;cell2&quot;> etc etc...

Put this code in the <head>:
<SCRIPT language=&quot;JavaScript&quot;>
<!--
function cell_colors(){
cell2.style.backgroundColor='#808080';
cell5.style.backgroundColor='red';
}
//-->
</SCRIPT>

And add this to the <body>-tag:
<body onload=&quot;cell_colors()&quot;>

Now all the cells are the original color except cells 2 & 5!

H.T.H.

Quasibobo

Don't eat yellow snow!
 
Here is an even better solution, but all the cells will end up the same color.

<td class=&quot;tableData&quot;>

this should be in the head section of you page:

<style>
td.tableData{
background-color:#000000;
}
</style>

one value, and <td>s with their class set to tableData.
 
alright, great. I got it workin. thanks!

Cyprus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top