PDA

View Full Version : table problem


Alias
11-06-2002, 02:45 PM
Hello

I have table wich changes background color onMouseOver ...
<table name="tname" onMouseOver="this.style.backgroundColor='#6F7578'" onMouseOut="this.style.backgroundColor='#B4B4BC'" width="100" border="0" cellspacing="0" cellpadding="0" height="50" bgcolor="#B4B4BC"><tr><td>&nbsp;</td></tr></table>

How to change background color of table on mouse over the image ???

something like ...
<img src="../bmp.gif" onMouseOver="tname.style.backgroundColor='#6F7578'" width="30" height="30" align="absmiddle">
but this don't works ...

Best Regrads
Vladimir

(IE only)

Jon Hanlon
11-06-2002, 05:30 PM
Alias, you are so close...
I remember being stuck with the same thing a few years ago, drove me crazy.

The trouble lies with name="tname".
The name attribute has been around since the beginning of HTML, but is only valid with certain elements.
The valid elements are A, IMG, and most FORM elements (Think - "not a picture nor a link nor user input = no name").

The id attribute was introduced so that you could identify pretty-much every element on the page.
Change name="tname" to be id="tname" and it will work fine (in IE).

A couple of things:
Color names make life a lot more readable. 'dimgray' means more than '#696969'. See http://msdn.microsoft.com/workshop/author/dhtml/reference/colors/colors.asp

The IE standard for attributes is lower-case. So we say onmouseover and onmouseout, instead of the (Netscape standard) onMouseOver and onMouseOut. Just a small thing but it can create trouble when you start coding functions.

Alias
11-06-2002, 05:40 PM
Thank You So Much Jon !!!!
Very usefull
You are great !!!

Best Regards