473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Generate random numbers in a range every second?

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
3 9139
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Levi Campbell | last post by:
Hi, I'm working on a random number generator using the internet as a way to gather entropy, I have two questions. 1. is there a way to capture the internet stream? 2. how would I skip every 2nd,...
3
by: jjmontreal | last post by:
I would like to create a form where by clicking some where in the form it will generate a alphanumeric sequence. I want to generate random PIN numbers preceeded with specific letters. An example...
9
by: Chelong | last post by:
Hi All I am using the srand function generate random numbers.Here is the problem. for example: #include<iostream> #include <time.h> int main() {
4
by: pitchke | last post by:
how do i generate random no's...also i want to convert that no. to the corresponding string...using PHP!!!!! thanks in advance.. Tarun
24
by: pereges | last post by:
I need to generate two uniform random numbers between 0 and 1 in C ? How to do it ? I looked into rand function where you need to #define RAND_MAX as 1 but will this rand function give me ...
5
by: DAXU | last post by:
Hi, I need to generate a fixed number of random integers that their summary equals to certain values. For example, the scenario can be: simulate user hits (e.g. 20000) within a hour (3600...
2
by: obtrs | last post by:
thanx. can u plz also tell me how to generate rondom numbers in a table and also how to show result of numbers? because when im showing contact no field which contains numbers its not showing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.