473,411 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Changing background colour in a table cell from a function

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?

Jul 20 '05 #1
3 14657
you have to cycle through some colors (style attribute background-color)
with JavaScript and use setTimeOut
"NeoPhreak" <ne*@neophreak.com> wrote in message
news:xm*******************@news20.bellglobal.com.. .
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?

Jul 20 '05 #2
Any chance someone could please help me out by starting me off... I'd really
appreciate it!

thnx
.< NeoPhreak
"Gill Bates" <g.*****@mothail.com> wrote in message
news:bg**********@netlx020.civ.utwente.nl... you have to cycle through some colors (style attribute background-color)
with JavaScript and use setTimeOut
"NeoPhreak" <ne*@neophreak.com> wrote in message
news:xm*******************@news20.bellglobal.com.. .
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?


Jul 20 '05 #3
Thanks!! Great Help!
.<NeoPhreak
"Richard Hockey" <ri***********@dsl.pipex.com> wrote in message
news:3f***********************@news.dial.pipex.com ... <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" <ne*@neophreak.com> wrote in message
news:1x*****************@news20.bellglobal.com...
Any chance someone could please help me out by starting me off... I'd

really
appreciate it!

thnx
.< NeoPhreak


"Gill Bates" <g.*****@mothail.com> wrote in message
news:bg**********@netlx020.civ.utwente.nl...
you have to cycle through some colors (style attribute background-color) with JavaScript and use setTimeOut
"NeoPhreak" <ne*@neophreak.com> wrote in message
news:xm*******************@news20.bellglobal.com.. .
> 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?
>
>
>



Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Holden Caulfield | last post by:
Hi there, for IE 5+ I need to be able to change certain TD tags´ background colors, and can´t figure out how to do it... For instance, in a table with 25 cells, somewhere between 5 or 10 will...
4
by: Dj Frenzy | last post by:
Hi, I know how to use javascript to change a background image to another background image, and how to change a background colour to another background colour. Is there a way to change an image to a...
4
by: david.graham18 | last post by:
Hi I spotted some nice code to change the background colour of a web page to one of four different colours at random but I can't find it now! The method was to select a number at random from 1...
31
by: Arthur Shapiro | last post by:
I'm the webmaster for a recreational organization. As part of one page of the site, I have an HTML "Calendar at a Glance" of the organization's events for the month. It's a simple table of a...
13
by: mike | last post by:
I have some elements that I want to change color when I mouse over them and them back on mouse off. I'd like the color to remain with "#c7d0e0" when the user clicks on them. <td...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
3
by: Yeah | last post by:
Through CSS, is there a way to change the color of a table cell on a hover? By the way, the cell also contains a link - the text link and table cell mouseover should both be clickable to the link's...
1
by: printline | last post by:
Hi' I have a problem with changing the background color in a table cell when i click on the content in the cell. Here is my code: <script type="text/javascript"> var ie = document.all...
3
Frinavale
by: Frinavale | last post by:
Hi there, I'm using JavaScript to highlight a row or column in a table. I have created a CSS class that changes the background colour to a light blue and I apply this class to the cells in the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.