Example : How to create timer for a web page up to a desired value [Sports Timer].
<form name="counter">
	<input type="text" size="8"name="d2">
</form> 

<script>
	 var milisec=0 
	 var seconds=1200 
	 document.counter.d2.value='30' 

	function display()
	{ 
	 if (milisec<=0)
	 { 
	    milisec=9 
	    seconds-=1 
	 } 
	 if (seconds<=-1)
	 { 
	    milisec=0 
	    seconds+=1 
	 } 
	 else 
	    milisec-=1 
	    document.counter.d2.value=seconds+":"+milisec 
	    setTimeout("display()",100) 
	}

	display(); 
</script>

Loading


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.