Morf
04-06-2006, 09:00 PM
Hello.
I'm trying to decrease my numeric variable in random increments from 0-4 every 5 seconds until this variable reaches 0. Basically it's a countdown, but has a random increment each count. Here's my code:
var position=Math.round(Math.random()*5000)
while (position < 4900)
{
position=Math.round(Math.random()*5000)
}
setTimeout ( "document.write(position)", 3000 );
While (position > 1)
{
var increment=Math.round(Math.random()*4);
position==(position-increment)
setTimeout ( "document.write(position)", 5000 );
}
Does anyone know why it is not working? It displays the first number generated after 3 seconds, and it is a number between 4900 and 5000, as intended, but does not change from there. Thanks for your help.
I'm trying to decrease my numeric variable in random increments from 0-4 every 5 seconds until this variable reaches 0. Basically it's a countdown, but has a random increment each count. Here's my code:
var position=Math.round(Math.random()*5000)
while (position < 4900)
{
position=Math.round(Math.random()*5000)
}
setTimeout ( "document.write(position)", 3000 );
While (position > 1)
{
var increment=Math.round(Math.random()*4);
position==(position-increment)
setTimeout ( "document.write(position)", 5000 );
}
Does anyone know why it is not working? It displays the first number generated after 3 seconds, and it is a number between 4900 and 5000, as intended, but does not change from there. Thanks for your help.