/    Sign up×
Community /Pin to ProfileBookmark

need help creating a dymanic counter

hi all,

i haven’t posted on here before tho i’ve looked around and think this is a great forum. sorry if this is not in the right place.

i’m having an issue creating a counter for a site. i need it to be dymanic, start at 1.25 million and increase by one every seven seconds. i need it to maintain the number (kind of the like the world population clock) and not reset every time a visitor visits the page.

i’m pretty stumped as to how to make this happen or even where to start looking.

thanks in advance for any help!

to post a comment
Full-stack Developer

3 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 21.2009 — <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript">
window.onload=fakeCounter;

function fakeCounter() {
var dateBegin=Date.parse(new Date(2009, 3, 21));
var dateNow=Date.parse(new Date());
var count=1250000 + parseInt((dateNow - dateBegin)/7000);
document.getElementById('counter').innerHTML=count;
timerID = window.setInterval(fakeCounter, 7000);
}
</script>

</head>
<body>
<div id="counter">1250000</div>
</body>
</html>
Copy linkTweet thisAlerts:
@lungodromauthorApr 21.2009 — wow! that is so awesome! thank you so much. i realized i mistyped...it should be every seven minutes not every seven seconds. to do that, do i just change the 7000?

thanks again so much
Copy linkTweet thisAlerts:
@FangApr 21.2009 — Yes, just change both values to your required time.
×

Success!

Help @lungodrom spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...