Page 1 of 1

[SOLVED]working with tables <td> and onmouseover

Posted: Wed Feb 15, 2006 10:48 am
by duk
hy,

i need some help, with this:

i have this table with all this rows and columns:
<tr>
<td width=\"5%\" bgcolor=\"$color\">&nbsp;&nbsp;$result[0]</td>
<td width=\"20%\" bgcolor=\"$color\">&nbsp;&nbsp;$result[3]</td>
<td width=\"20%\" bgcolor=\"$color\">&nbsp;&nbsp;$result[4]</td>
<td width=\"30%\" bgcolor=\"$color\">&nbsp;&nbsp;$result[5] $result[6]</td>
<td width=\"25%\" >&nbsp;</td>
</tr>
i just understand the basic of CSS and javascript, i need some help that is:

each time the mouse goes over for example of the first <td> the rest of the others <td> in the same row<tr> they need to change the background to and not just one <td>...

can someone give me a help on this one... thanks

Posted: Wed Feb 15, 2006 11:24 am
by Grim...

Code: Select all

<tr onMouseOver="this.style.
backgroundColor='#0000FF'" onMouseOut ="this.style.backgroundColor='#FFFFFF'">
Change the first hex color (#0000FF) to whatever you want, and the second one to your background colour.

Posted: Wed Feb 15, 2006 11:29 am
by duk
nice, in fact hy was using that, but i didn't know and i didn't think that i could use in <tr> i was using in <td's>, so excelente :D

thanks a lot

Posted: Wed Feb 15, 2006 11:33 am
by Grim...
You can use it on any element - <tr>, <td>, <table>, <div>, <a>, etc...

Posted: Thu Feb 16, 2006 3:51 am
by duk
why this didn't work ?
<tr onMouseOver=\"this.style.backgroundColor='#A2F196'\" onMouseOut=\"this.style.backgroundColor='$color'\">
<td width=\"7%\" bgcolor=\"$color\" align=\"center\">$result[0]</td>
<td width=\"25%\" bgcolor=\"$color\">&nbsp;&nbsp;$result[1]</td>
<td width=\"25%\" bgcolor=\"$color\">&nbsp;&nbsp;$result[2]</td>
<td width=\"30%\" bgcolor=\"$color\">&nbsp;&nbsp;$result[3]&nbsp;/&nbsp;$result[4]</td>
<td width=\"13%\" >&nbsp;</td>
</tr>
work but just for the last td that dont have bgcolor the other ones dont have any effect and i have done some tests and if i remove bg color from the other td's it works, so i need something like if else or there is other way ?

Posted: Thu Feb 16, 2006 8:15 am
by Grim...
Just set the color in your <tr> and not your <td>.

Code: Select all

<tr style=\"background-color: $color\" onMouseOver=\"this.style.backgroundColor='#A2F196'\" onMouseOut=\"this.style.backgroundColor='$color'\">
<td width=\"7%\" align=\"center\">$result[0]</td>
...

Posted: Thu Feb 16, 2006 11:27 am
by duk
perfect thanks a lot