473,387 Members | 1,745 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,387 software developers and data experts.

help with setTimeout

cjl
Hey all:

In my script I have the following:

change_opacity (0, id);
for (var x = 0; x<=100; x=x+1)
{
change_opacity( x, id );
}

This works. I want to convert this to a "setTimeout" call, so that it
occurs more slowly. So I try:

change_opacity (0, id);
for (var x = 0; x<=100; x=x+1)
{
setTimeout( "change_opacity(" + x +"," + id + ")", 200 );
}

But it doesn't work. I'm stuck.

-CJL

Oct 23 '05 #1
6 1219
cjl
Hey:

I just found this:

http://groups.google.com/group/comp....505d898bffb1b0

Which sort of explains why I was having a problem.

I re-assigned my 'id' variable to a global, and now things are working.

-CJL

Oct 24 '05 #2
cjl wrote:
Hey all:

In my script I have the following:
[...]

But it doesn't work. I'm stuck.


See manu3d's post below for a much better version.

--
Rob
Oct 24 '05 #3
RobG wrote on 24 okt 2005 in comp.lang.javascript:
See manu3d's post below for a much better version.


What is "below" on usenet, if it is not in your posting?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 24 '05 #4
JRS: In article <11**********************@g47g2000cwa.googlegroups .com>
, dated Sun, 23 Oct 2005 16:47:47, seen in news:comp.lang.javascript,
cjl <cj****@gmail.com> posted :
Hey all:
Rather ill-mannered - are you an infant Merkin or just a wannabe?
In my script I have the following:

change_opacity (0, id);
for (var x = 0; x<=100; x=x+1)
{
change_opacity( x, id );
}

This works. I want to convert this to a "setTimeout" call, so that it
occurs more slowly. So I try:

change_opacity (0, id);
for (var x = 0; x<=100; x=x+1)
{
setTimeout( "change_opacity(" + x +"," + id + ")", 200 );
}

But it doesn't work. I'm stuck.


I expect it does work; it just does what you told it to do, instead of
what you wanted to so.
Your code sets, as fast as possible, 101 200 ms timeouts. Ideally, 200
ms later, they would all fire in corresponding sequence. In practice,
after about 200 ms, they'll fire probably in either the right order or
possibly the reverse order.

What you should do is to seek some clock code and modify it to not
continue after Number 100. In a clock, each second starts when the
previous one finishes; they do not all start at once. Presumably you
did not read the newsgroup FAQ thoughtfully?

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 24 '05 #5
Evertjan. wrote:
RobG wrote on 24 okt 2005 in comp.lang.javascript:

See manu3d's post below for a much better version.

What is "below" on usenet, if it is not in your posting?


Fair enough. :-x

It was 'below' to me since I like the new stuff at the top and older
stuff at the bottom, but maybe a link would have been better...
--
Rob
Oct 25 '05 #6
cjl
John:
Rather ill-mannered - are you an infant Merkin or just a wannabe?
Did you just call me a pubic hair wig? I guess a reply is in order.
Your mother is a toothless whore.
Your code sets, as fast as possible, 101 200 ms timeouts. Ideally, 200
ms later, they would all fire in corresponding sequence. In practice,
after about 200 ms, they'll fire probably in either the right order or
possibly the reverse order.
I see.
What you should do is to seek some clock code and modify it to not
continue after Number 100. In a clock, each second starts when the
previous one finishes; they do not all start at once.
Now that it a helpful reply, thank you. It seems I should apologize
for sullying the good name of your mother.
Presumably you did not read the newsgroup FAQ thoughtfully?


Hmmm. I tried to read it, but your mother kept begging me for another
shag.

-CJL

Oct 25 '05 #7

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

Similar topics

3
by: Dennis M. Marks | last post by:
There is no problem with the following function. I want to insert code at the point that the function does not repeat. I was pretty sure that it could be inserted at the /// but that repeats with...
14
by: Brandon Hoppe | last post by:
I'm trying to change the src of an ilayer in the parent document from a link inside the ilayer. I'm not able to get it to work. All that happens is Netscape 4 crashes. This is for Netscape 4 only....
4
by: Mool | last post by:
I want to use a setTimeout to just loop for a number of seconds, then fall through to the next bit of code...can this be done by using some kind of null in the statement, or do I have to assign the...
4
by: Ken | last post by:
Hello I am trying to change the color of a font in a text box. I have been reading about and trying various examples found it this group, but still can't get it right. Here is where I am...
3
by: P Wolpert | last post by:
This is my first post. I hope I don't sound stupid. I have a script conflict when I put two scripts on one page. Both scripts will work if I use one at a time but the menu button script will not...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
12
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
4
by: E | last post by:
I am having trouble with setTimeout working on a second call to the setTimeout function from a second page which is an html page. Here is the scenario. I have a web page and onload it calls a...
2
by: jasonchan | last post by:
I am trying to have a function start with a timer and then switch to another function. However, it is not working at all. Anyone know whats goin on? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.