Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help needed in setTimeout - Javascript

 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a problem working with the setTimeout method of Javascript

What i do is i call a setTimeout method inside a Javascript.

I want to print a name on the screen, with some delay between the successive
characters. i have a method, which will print the character at the
given index of the name array, and another method to call this method,
within a for loop, with time out, specified for the method.

My code snippet is


That doesn't work.

Any idea?

Cheers,
Swamy.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use setInterval and then clear it when you printed out the whole string. Use a counter variable to keep track of the position.

Plus an error with your code: you are passing the string "i" and not the integer i. and you are missing a closing brace }


Eric

[ October 13, 2004: Message edited by: Eric Pascarello ]
[ October 13, 2004: Message edited by: Eric Pascarello ]
 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,

Thanks for the tip...I think i would have pasted it with some missing paranthesis. But when i try running the code, i am noe prompted for an error.

Well...could you please expand a bit on setTimeout() and setInterval()?

Thanks in advance.

Cheers,
Swamy
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the basic idea:

 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,

Thanks a lot for the simple, pellucid, and beautiful, etc, etc, code.

That's working great...Now i got the concept clear....

Thanks a lot....



Cheers,
Swamy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic