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

need a sequential number generator in javascript

P: 1
I was on the web trying to find a javascript that would allow me to input a number on my website and have it increase by a given percentage every second.

During my search I found the Earth Population Calculator on the site. The Calculator functions just as I imagine I want my number generator to function, but I need it to present a different number.

I work for a non profit organization that administers Head Start and other federal and state social service programs. We would like to put a counter on our website that shows the total dollars saved nationally as a result of the services agencies such as ours provide to children and parents from low-income families. For example, (for the moment Iím guessing at these numbers) letís say that up to this point in time, $5,000,000 has been saved, and every second after that another $500 is saved.

Could anyone help me by telling me how to create a javascript that could be allow me to input the starting number ($5,000,000) and also inputting the number I need it to increase by per second? Once I get the starting number in, and the increase per second, I want it to continue running without any further input, just as the Earth Population Calculator does.

Iíve spent the past few days searching the internet for an answer to my problem but havenít been able to find a sequential number generator.The Earth Population Calculator is the closest thing Iíve been able to find that demonstrates what I need.

We are using FrontPage for our web development, but I have a new site Iíve created using Dreamweaver that I hope to be able to replace the FrontPage site with soon.

I would really appreciate any help you can give me.

Thank you,
Jun 7 '07 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 15k+
P: 16,027
See the setInterval method.
Jun 8 '07 #2

P: 3
It is a simple program:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. var numat = 5000000
  6. function numberchange(){
  7.     numat += 500
  8.     document.getElementById("numspace").innerHTML = "$" + numat + " Saved"
  9.     setTimeout("numberchange()",1000)
  10. }
  11. </script>
  12. </head>
  13. <body onLoad="setTimeout('numberchange()',1000)">
  14. <div id="numspace">$5000000 Saved</div>
  15. </body>
  16. </html>
Jan 27 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.