473,563 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 14676
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******** ***********@new s20.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.*****@mothai l.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******** ***********@new s20.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.pipe x.com... <script type="text/javascript">
function cellbg(cellid,c ellcolour)
{
// 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=cellcol our.split(',');
if(CellList.len gth!=ColList.le ngth || CellList.length ==0 ||
ColList.length= =0) return false;

// actually change the cell colour
for(n=0;n<CellL ist.length;n++)
{
document.getEle mentById(CellLi st[n]).style.backgro undColor=ColLis t[n];
}
}
</script>

and in your table

<tr>
<td id="a1" onMouseOver="ce llbg('a1','#eee eee');"
onMouseOut="cel lbg('a1','#ffff ff');">a1</td>
<td id="a2" onMouseOver="ce llbg('a2','#eee eee');"
onMouseOut="cel lbg('a2','#ffff ff');">a2</td>
<td><a href="#" onMouseOver="ce llbg('a1,a2','# 00ff00,#00ff00' );"
onMouseOut="cel lbg('a1,a2','#f fffff',#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******** *********@news2 0.bellglobal.co m...
Any chance someone could please help me out by starting me off... I'd

really
appreciate it!

thnx
.< NeoPhreak


"Gill Bates" <g.*****@mothai l.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******** ***********@new s20.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
5190
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 need the bgcolor to change at the same time when a user clicks a button. Right now only one changes when I use something like this... ...
4
2469
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 backgound colour? I have a table with a background that has a picture. When the user hovers over the picture I want the background to change to...
4
1959
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 to 4 by using the rnd() function and then dividing by modulus 4. The result was then used to select a cell in a 4 cell array which was holding a...
31
5675
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 calendar, 7 across by whatever needed down, and I manually create it each month - not a big deal. Every day I go in and darken the background color of...
13
1849
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 style="cursor:hand;" onMouseOver="this.style.background='#c7d0e0';" onMouseOut="this.style.background='#ffffff';" onClick="chg_the_color();">
3
4742
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
9852
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 destination... Thanks!
1
2102
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 var ns = document.getElementById && !ie
3
10529
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 selected row/column. It works great most of the time but sometimes the cell may have an inline style sets background colour to yellow. This, of...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6250
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.