Generate random numbers in a range every second?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • -[ CaMeL ]- a55m0nk

    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)
  • Lasse Reichstein Nielsen

    #2
    Re: Generate random numbers in a range every second?

    jackmancantbrea the@hotmail.com (-[ CaMeL ]- a55m0nk) writes:
    [color=blue]
    > 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[/color]

    <p>Users online: <span id="usersFake"> </span></p>
    <script type="text/javascript">
    var numberText = document.create TextNode("");
    document.getEle mentById("users Fake").appendCh ild(numberText) ;
    function updateFakeUsers () {
    numberText.node Value = Math.floor(Math .random()*50000 0)+100000;
    }
    updateFakeUsers ();
    setInterval(upd ateFakeUsers,10 00);
    </script>

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

    Comment

    • Lee

      #3
      Re: Generate random numbers in a range every second?

      -[ CaMeL ]- a55m0nk said:[color=blue]
      >
      >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.[/color]


      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.

      Comment

      • -[ CaMeL ]- a55m0nk

        #4
        Re: Generate random numbers in a range every second?

        Lasse Reichstein Nielsen <lrn@hotpop.com > wrote in message news:<ismlp1zv. fsf@hotpop.com> ...[color=blue]
        > jackmancantbrea the@hotmail.com (-[ CaMeL ]- a55m0nk) writes:
        >[color=green]
        > > 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[/color]
        >
        > <p>Users online: <span id="usersFake"> </span></p>
        > <script type="text/javascript">
        > var numberText = document.create TextNode("");
        > document.getEle mentById("users Fake").appendCh ild(numberText) ;
        > function updateFakeUsers () {
        > numberText.node Value = Math.floor(Math .random()*50000 0)+100000;
        > }
        > updateFakeUsers ();
        > setInterval(upd ateFakeUsers,10 00);
        > </script>
        >
        > /L[/color]

        Thanks for your help it worked great :P

        Comment

        Working...