Link to home
Start Free TrialLog in
Avatar of aristanoble
aristanoble

asked on

Javascript Counter Like Google's Space counter or Walmarts Savings counter

Hello Experts, I'm looking for a code snippet of a Javascript counter similar to Google's "Lots of Space" counter found on their mail home page or similar to Walmart's American Savings counter found on their homepage. Both are rolling counters. In the Walmart example it shows how many dollars they've saved american families. (See attached image of Walmart example).

I need a counter that will count how much my company donated to charity. So similar to the attached jpg file, it would display the rolling dollar amount donated.

Can you please provide me with the code that would adequately solve this problem?

I'm currently employing php and mysql. Its safe to assume the sum total contributed will come from a mysql table and the browser will reflect an incrementing counter.
wlmrt-cntr.jpg
Avatar of MatthiasVance
MatthiasVance
Flag of Netherlands image

You would need to use a timer and the XmlHttpRequest to query a php page which would contact your mysql database to retrieve a total and then let the javascript update your content accordingly.

More information about the XmlHttpRequest can be found here:
http://developer.apple.com/internet/webcontent/xmlhttpreq.html
http://www.w3schools.com/XML/xml_http.asp

If you need more help, just post a reply and I'll provide some sample code.

Kind regards,

Matthias Vance
Avatar of ddrudik
It appears that Google's counter is just a JS estimation of the storage over time based on the current date/time, view their page source for the code used.
Walmart's site has a careful disclaimer with their savings counter, I would suspect it is also just an estimation based on current date/time.
Avatar of aristanoble
aristanoble

ASKER

Yes Matthais I would need a bit more help. Viewing the Google source code only reminded my how I never understood Japanese (it was all foreign to me). I'm totally a beginner in javascript, even more so with Ajax, but it's important that I utilize this display method, albeit estimation values. I would greatly appreciate the code please.
ASKER CERTIFIED SOLUTION
Avatar of MatthiasVance
MatthiasVance
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Now is it IE-7 specific due to the use of 'XMLHttpRequest'; I've been reading that different browsers require different request methods, the solutions for that look simple enough to implement. I'll get working on that and post my results.