• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help needed in setTimeout - Javascript

 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the basic idea:

 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic