[SOLVED]working with tables <td> and onmouseover

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

[SOLVED]working with tables <td> and onmouseover

Post 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
Last edited by duk on Thu Feb 16, 2006 11:27 am, edited 1 time in total.
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post 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.
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post 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
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

You can use it on any element - <tr>, <td>, <table>, <div>, <a>, etc...
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post 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 ?
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post 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>
...
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post by duk »

perfect thanks a lot
Post Reply