Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Whats wrong with this?

Reply
Thread Tools

Whats wrong with this?

 
 
NeoPhreak
Guest
Posts: n/a
 
      08-14-2003
This function is called on the onMouseOut even of a table cell for a menu.
I want it to sort of fade out but for some reason i can't get it to work.
If some one could help me out on this one i would greatly appreciate it.

function out(obj)
{
var colors = new Array(5);
colors[0]='#006666';
colors[1]='#003333';
colors[2]='#002222';
colors[3]='#001111';
colors[4]='';

for(i=0; i<5; i++)
{
setTimeout("return","200");
obj.style.backgroundColor= colors[i];
}
}

would be called like this:
<td onMouseOut="Out(this);">Something</td>

Thanks in advance.

NeoPhreak >.<


 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      08-14-2003
"NeoPhreak" <(E-Mail Removed)> writes:

> This function is called on the onMouseOut even of a table cell for a menu.
> I want it to sort of fade out but for some reason i can't get it to work.
> If some one could help me out on this one i would greatly appreciate it.


....
> setTimeout("return","200");


What is this line supposed to do?
What it actually does is to schedule the execution of the statement
"return" in 200 milliseconds ... which ofcourse does nothing whatsoever.
It doesn't delay execution of the following statements at all (which is
what I guess you wanted it to).

> would be called like this:
> <td onMouseOut="Out(this);">Something</td>


You function is called "out" with a small "o", but this call is to a
function with a captial "O". Javascript is case sensitive.

Try this:
---
var colors = ["","#011","#022","#033","#066"];
function fade(obj) {
var ctr = colors.length-1;
function fadeStep() {
obj.style.backgroundColor = colors[ctr--];
if (colors<0) {clearInterval(tid);}
}
var tid = setInterval(fadeStep,200);
}
---

/L
--
Lasse Reichstein Nielsen - http://www.velocityreviews.com/forums/(E-Mail Removed)
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
 
Douglas Crockford
Guest
Posts: n/a
 
      08-14-2003
> var colors = new Array(5);
> colors[0]='#006666';
> colors[1]='#003333';
> colors[2]='#002222';
> colors[3]='#001111';
> colors[4]='';


You should consider using the array literal notation.

var colors = ['#006666', '#003333', '#002222', '#001111', ''];

It is smaller, faster, easier, prettier.

http://www.JSON.org


 
Reply With Quote
 
NeoPhreak
Guest
Posts: n/a
 
      08-15-2003
Thanks guys.. got it working fine now

NeoPhreak >.<


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Whats Wrong With This Router Howard Huntley Cisco 2 04-10-2006 08:54 PM
routing problems with multiple T1s - I know whats wrong but dont know how to fix it Jason Cisco 5 03-10-2006 01:03 AM
I don't know whats wrong!!! =?Utf-8?B?S2lt?= Wireless Networking 2 09-08-2005 08:21 AM
Whats wrong with .net passport and IE =?Utf-8?B?S2ViaXNob3AzMQ==?= MCSE 2 10-14-2004 01:59 PM
Whats wrong with this provider ?? Alexandre Martins ASP .Net 5 08-14-2003 08:05 PM



Advertisments