aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Help needed in setTimeout - Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Help needed in setTimeout - Javascript" Watch "Help needed in setTimeout - Javascript" New topic
Author

Help needed in setTimeout - Javascript

Ramaswamy Srinivasan
Ranch Hand

Joined: Aug 31, 2004
Posts: 295
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Aug 31, 2004
Posts: 295
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
This is the basic idea:

Ramaswamy Srinivasan
Ranch Hand

Joined: Aug 31, 2004
Posts: 295
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help needed in setTimeout - Javascript