settimeout

J

j van c

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>
 
O

Olaf Studt

j van c said:
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
 
J

j van c

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

j van c

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.
 
N

Nico Schuyt

j said:
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 :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top