PDA

View Full Version : change BKGD of cell?


Yanhead
07-08-2004, 06:19 PM
is there a way of making a link (text or graphic) when clicked, change the background colour of a cell of a table?

Cheers

Subjective Effe
07-08-2004, 07:28 PM
Yes. img onclick="changer()"

Then in the HEAD in the SCRIPT section:
function changer(){
Colour change code I don't have.
Basically it will say:
tablename.background.color = "blue"
}

But you'll have to check the DOM cuz I can never remember :D

agent002
07-09-2004, 01:24 AM
I wouldn't use the function in the header, unless many links change the same cell's bg color... here's my suggestion:
<a href="url here" onclick="document.getElementById('id of table cell').style.backgroundColor = 'new color';
return false;">Click here</a>
Then the table cell that gets it bg color changed has to have an id attribute.

Subjective Effe
07-09-2004, 05:39 AM
Aye, thats the DOM done.

I WOULD put in the header as not only will multiple links be able to change the color but you can use it on multple cells too.

And the inline method by agent (above) requires you put code in every anchor, my version just the function call.

Choice is yours.