Hi,
I would like to reproduce the counter present in the header of the page http://www.ensembleverslavenir.ca/fr/accueil/
The calculation code looks easy (check below), but there has a cookies system (or an ASP code that I would like to convert in PHP), which allow the counter to continue from page to page (idem if you did a page refresh).
Perhaps an ID is created whenever the browser opens a session on the site?
The counter restarts at zero when the browser leaves the site.
Would you have an idea of how to re-encode the same system but in PHP?
Thanks a lot
Chris
<div class="counter"><span id="counter">8.15</span> tonnes</strong> de gaz à effet de serre ont été émis au Québec depuis le début de votre visite.</div>
<script language="JavaScript" type="text/javascript">
var sTotal = 0;
function gazCount(){
sTotal=sTotal+(0.1);
document.getElementById("counter").innerHTML = r2(sTotal*2.91);
//document.getElementById("counter").innerHTML = r2(sTotal);
setTimeout("gazCount();", 100);
}
function r2(n){
ans = n * 1000
ans = Math.round(ans /10) + ""
while (ans.length < 3) {ans = "0" + ans}
len = ans.length
ans = ans.substring(0,len-2) + "." + ans.substring(len-2,len)
return ans
}
gazCount();
</script>
Bookmarks