Can you tell me how to do this

Discussion in 'JavaScript' started by login, Nov 3, 2007.

  1. #1
    login, Nov 3, 2007 IP
  2. KatieK

    KatieK Active Member

    Messages:
    116
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #2
    You're talking about the automatically scrolling numbers, right?

    You will need JavaScript to do that, because it's a change on the client side.

    You'll need to start with something that automatically refreshes the page:

    
    <script type="text/javascript">
      setInterval('yourFunction()', 5000);
    </script>
    Code (markup):
    That will run the function yourFunction() every 5000 miliseconds, or five seconds. Here's an example yourFunction() you could use:


    
    <script type="text/javascript">
      function yourFunction()
      {  
          var output;  //  The number you will write to the page
          output = output + 1;
          document.getElementById("input1").value = output;  //  In this example, your HTML would have an input area with an id of "input1"
      }
    </script>
    
    Code (markup):
    That script would add 1 to output, and update the page with output every time it was run. Of course, you'll need to use your own formulas instead of just adding one like in the example.
     
    KatieK, Nov 3, 2007 IP