svgmx5 Posted September 28, 2010 Share Posted September 28, 2010 has anyone made a counter before that increases every 2 seconds? it doe not have to increase every time a user clicks on something, it just has to increase by itself every 2 seconds Link to comment https://forums.phpfreaks.com/topic/214589-help-creating-a-counter/ Share on other sites More sharing options...
gizmola Posted September 28, 2010 Share Posted September 28, 2010 Sure, you can use the javascript setInterval function. Here's a sample that sets up a form element and updates it every 2 seconds. <br /> function init() {<br /> document.forms["form1"].counter.value=0;<br /> }<br /> <br /> function updateCounter(){<br /> document.forms["form1"].counter.value++;<br /> }<br /> <br /> window.onload=function(){<br /> init();<br /> setInterval(updateCounter, 2000);<br /> }<br /> </pre> <form name="form1"> Counter: </form> <br><b Link to comment https://forums.phpfreaks.com/topic/214589-help-creating-a-counter/#findComment-1116645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.