By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,608 Members | 1,925 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,608 IT Pros & Developers. It's quick & easy.

Generate random numbers in a range every second?

P: n/a
I have attempted to create a javascript that displays on the page a
random number between 100,000 and 600,000, and then displays a new
random number in the same place every second after that. It is for a
fake users online for a gag website i am making in school.

any help would be much appreciated

a55m0nk
(jack)
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ja****************@hotmail.com (-[ CaMeL ]- a55m0nk) writes:
I have attempted to create a javascript that displays on the page a
random number between 100,000 and 600,000, and then displays a new
random number in the same place every second after that. It is for a
fake users online for a gag website i am making in school.

any help would be much appreciated


<p>Users online: <span id="usersFake"></span></p>
<script type="text/javascript">
var numberText = document.createTextNode("");
document.getElementById("usersFake").appendChild(n umberText);
function updateFakeUsers() {
numberText.nodeValue = Math.floor(Math.random()*500000)+100000;
}
updateFakeUsers();
setInterval(updateFakeUsers,1000);
</script>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
Lee
-[ CaMeL ]- a55m0nk said:

I have attempted to create a javascript that displays on the page a
random number between 100,000 and 600,000, and then displays a new
random number in the same place every second after that. It is for a
fake users online for a gag website i am making in school.

If you want it to seem believable at all, you might consider
having it start at a number somewhere in that range and each
second add a random number between -10,000 and +10,000.

That will avoid jumps of several hundred thousand people per
second.

Jul 20 '05 #3

P: n/a
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<is**********@hotpop.com>...
ja****************@hotmail.com (-[ CaMeL ]- a55m0nk) writes:
I have attempted to create a javascript that displays on the page a
random number between 100,000 and 600,000, and then displays a new
random number in the same place every second after that. It is for a
fake users online for a gag website i am making in school.

any help would be much appreciated


<p>Users online: <span id="usersFake"></span></p>
<script type="text/javascript">
var numberText = document.createTextNode("");
document.getElementById("usersFake").appendChild(n umberText);
function updateFakeUsers() {
numberText.nodeValue = Math.floor(Math.random()*500000)+100000;
}
updateFakeUsers();
setInterval(updateFakeUsers,1000);
</script>

/L


Thanks for your help it worked great :P
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.