Results 1 to 7 of 7

Thread: <td> bgcolor

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    123

    Exclamation how do i change <td> bgcolor??

    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

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Posts
    123
    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    123
    uhh i said in my post that i tryed that and it doesnt work for <td>

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    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:


    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>
    Mark
    -------------------

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    123
    thanks, this accomplishes the same task. nice tip :-)

  6. #6
    Junior Member
    Join Date
    May 2000
    Posts
    28
    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.
    Code:
    <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>

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    123
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width