settimeout

Discussion in 'HTML' started by j van c, Dec 5, 2003.

  1. j van c

    j van c Guest

    why doesn't my code work? It' s just showing "W" on a document. It should be
    "WELKOM" showing each letter with a delay of 1 second.
    What is the meaning of "+j+" in de function call toon()?

    <html>
    <SCRIPT LANGUAGE = "JavaScript">
    function doe()
    {zin = "WELKOM";
    lengte = zin.length;
    j=1;
    while (j<=lengte){
    setTimeout("toon("+j+")", 1000);
    j++ ;
    }
    }
    function toon(z)
    {
    tekst= zin.substring(0,z);
    document.write(tekst);

    }
    </SCRIPT>
    <BODY onload="doe()">

    </BODY>
    </html>
     
    j van c, Dec 5, 2003
    #1
    1. Advertising

  2. j van c

    Nico Schuyt Guest

    Nico Schuyt, Dec 5, 2003
    #2
    1. Advertising

  3. j van c

    Olaf Studt Guest

    "j van c" <> wrote:
    > why doesn't my code work? It' s just showing "W" on a document. It should be
    > "WELKOM" showing each letter with a delay of 1 second.


    I'm afraid your script overwrites itself in the first "document.write".

    > What is the meaning of "+j+" in de function call toon()?

    ....
    > setTimeout("toon("+j+")", 1000);


    A string like "toon(3)" is concatenated from "toon(",
    the index, and ")".

    HTH
    --
    Olaf from THE Hamburg (not home of hamburgers)
    Replace laundry basket by my last name to avoid ending up in such.
     
    Olaf Studt, Dec 6, 2003
    #3
  4. j van c

    j van c Guest

    Nico,
    can you explain to me why your code doesn't work with document.write in
    stead of with a form and a textarea?
     
    j van c, Dec 7, 2003
    #4
  5. j van c

    j van c Guest


    > > What is the meaning of "+j+" in de function call toon()?

    > ...
    > > setTimeout("toon("+j+")", 1000);

    >
    > A string like "toon(3)" is concatenated from "toon(",
    > the index, and ")".

    Of course. I thought is was more a construction like j++(adding one and then
    doiing something else.)but i couldn't figure out what.
    Thanks.
     
    j van c, Dec 7, 2003
    #5
  6. j van c

    Nico Schuyt Guest

    j van c wrote:
    > Nico,
    > can you explain to me why your code doesn't work with document.write
    > in stead of with a form and a textarea?


    I think you have to specify the element where it shows.
    document.forms[1].elements[0].value for example will show the typewriter in
    the first element of the second form.
    Nico
    BTW Read: http://html-faq.com/etiquette/?quoting :)
     
    Nico Schuyt, Dec 7, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Pickering

    Smart navigation and js setTimeout

    Andy Pickering, Oct 24, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    505
    Andy Pickering
    Oct 27, 2003
  2. JR

    setTimeout

    JR, Apr 15, 2004, in forum: HTML
    Replies:
    3
    Views:
    547
    Whitecrest
    Apr 15, 2004
  3. =?Utf-8?B?RQ==?=

    javascript setTimeout does not work

    =?Utf-8?B?RQ==?=, May 2, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    8,839
    =?UTF-8?B?R8O2cmFuIEFuZGVyc3Nvbg==?=
    May 2, 2006
  4. Colin Brown

    socket settimeout ?

    Colin Brown, Dec 3, 2003, in forum: Python
    Replies:
    0
    Views:
    621
    Colin Brown
    Dec 3, 2003
  5. Replies:
    1
    Views:
    779
    Lawrence D'Oliveiro
    Apr 7, 2006
Loading...

Share This Page