Changing background colour in a table cell from a function

N

NeoPhreak

I am creating a menu for my site and I would like it so that when the
onMouseOut even is triggered it will cause the cell of the table to fade out
back to the normal color with a delay.

Can anyone help me to get started on how i would accomplish this?
 
G

Gill Bates

you have to cycle through some colors (style attribute background-color)
with JavaScript and use setTimeOut
 
N

NeoPhreak

Any chance someone could please help me out by starting me off... I'd really
appreciate it!

thnx
 
N

NeoPhreak

Thanks!! Great Help!
.<NeoPhreak

Richard Hockey said:
<script type="text/javascript">
function cellbg(cellid,cellcolour)
{
// accept single cell id and colour, or comma seperated list of cell ids
and cell colours

// check to see if number of cells and number of colours match, if not exit
the function
var CellList=cellid.split(',');
var ColList=cellcolour.split(',');
if(CellList.length!=ColList.length || CellList.length==0 ||
ColList.length==0) return false;

// actually change the cell colour
for(n=0;n<CellList.length;n++)
{
document.getElementById(CellList[n]).style.backgroundColor=ColList[n];
}
}
</script>

and in your table

<tr>
<td id="a1" onMouseOver="cellbg('a1','#eeeeee');"
onMouseOut="cellbg('a1','#ffffff');">a1</td>
<td id="a2" onMouseOver="cellbg('a2','#eeeeee');"
onMouseOut="cellbg('a2','#ffffff');">a2</td>
<td><a href="#" onMouseOver="cellbg('a1,a2','#00ff00,#00ff00');"
onMouseOut="cellbg('a1,a2','#ffffff',#ffffff);" onClick="return
false;">row</a></td>
</tr>

the function can handle single or multiple cells and has been tested with IE
6 and Netscape 7

NeoPhreak said:
Any chance someone could please help me out by starting me off... I'd really
appreciate it!

thnx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top