PDA

Click to See Complete Forum and Search --> : <td> bgcolor


highlife
Aug 1st, 2000, 03:02 PM
I want to change a <td> bgcolor property with a mouseover event, and then change in back with a mouseout.

for example:

<td align="center" onMouseOver="changebackground" onMouseOut="originalbackground" bgcolor="gray"><font face="fantasy" color=#FF6600> WEBSITES </font></td>

i tryed just giving the <td> an id and changing the bgcolor as an object and also tryed using a style sheet and accessing it that way, and tryed "this.bgcolor=black" ... none of these seemed to work

can anyone give me any suggestions on how to do this?

thanks,
zack

ravcam
Aug 1st, 2000, 06:54 PM
While I am no expert on HTML or scripting... I took a look at some sources and as far as I can tell you can do it using scripting event like onMouseOver but you still need to declare a scripting language... and also it seems to set a property you need to use the syntax of... onMouseOver='this.bgcolor="Blue";' or at least that is similar to the example they give... bear in mind I am not entirly sure (as I have not tried anything useing scripting events before) of this but hopefully it will give you some help.

highlife
Aug 2nd, 2000, 08:47 AM
uhh i said in my post that i tryed that and it doesnt work for <td>

Mark Sreeves
Aug 2nd, 2000, 02:40 PM
I don't think you can change the bgcolor of a cell.

BUT, wait, don't go away just yet! :)

With IE4 you can change the background picture of a cell.

I don't think this is possible with NS though.

So, all you need is 2 small GIFs the required colours and this code:



<html>

<body>

<TABLE><TR>
<TD ID="td1" onMouseover="document.all.td1.background='blue.gif'" onMouseout="document.all.td1.background='red.gif'" background='red.gif'>hello</TD>
<TD ID="td2" onMouseover="document.all.td2.background='blue.gif'" onMouseout="document.all.td2.background='red.gif'" background='red.gif'>hello</TD>
</TR><TR>
<TD ID="td3" onMouseover="document.all.td3.background='blue.gif'" onMouseout="document.all.td3.background='red.gif'" background='red.gif'>hello</TD>
<TD ID="td4" onMouseover="document.all.td4.background='blue.gif'" onMouseout="document.all.td4.background='red.gif'" background='red.gif'>hello</TD>
</TR></TABLE>
</body
</html>

highlife
Aug 2nd, 2000, 03:32 PM
thanks, this accomplishes the same task. nice tip :-)

billyo
Aug 4th, 2000, 10:39 PM
Dear Highlife,

I hope you haven't been terribly mislead,
by the bizarre comments made in this thread.
The colors of cells are easy to change,
and using gifs is really quite strange.
bgcolor failed because it's all lower case,
try again, but use bgColor in it's place.

<html>
<head>
</head>
<body>
<table width="200" height="200" border=1><tr>
<td onmouseover="this.bgColor='00ff00'" onmouseout="this.bgColor='ff00ff'">
</td></tr></table>
<table width="200" height="200" border=1><tr>
<td onmouseover="this.bgColor='ffaa00'" onmouseout="this.bgColor='ffff00'">
</td></tr></table>
</body>
</html>

highlife
Aug 6th, 2000, 02:25 PM
hmmm, such a simple answer ... thanks for your help. I didn't know JavaScript properties are case sensitive.

you don't realize I have looked through 3 JavaScript books, and all over the web for this answer!

thanks again