School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

JavaScript Source Code


Welcome to Dream.In.Code
Become an Expert!

Join 340,116 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 4,294 people online right now. Registration is fast and FREE... Join Now!




Countdown timer

a timer but it countsdown

Submitted By: deadlypetal
Actions:
Rating:
Views: 19,998

Language: JavaScript

Last Modified: April 14, 2005
Instructions: just paste it in your html

Snippet


  1. <html>
  2. <head>
  3.  
  4. <script>
  5. function countdown(){
  6.      x=frmcountdown.counter.value;
  7.      x--;
  8.      frmcountdown.counter.value=x;
  9.      if (x>0){
  10.           setTimeout("countdown()",1000);
  11.      }
  12.      else{
  13.           alert("out of time");
  14.      }
  15. }
  16.  
  17. </script>
  18. </head.
  19.  
  20. <body>
  21. <form name="frmcountdown">
  22.  
  23. <input type="text" name="counter" size="3" value=20 />
  24. <input type="button" value="start" onclick='setTimeout("countdown()",1000);'>
  25. </form>
  26.  
  27. </body>
  28. </html>

Copy & Paste


Comments

kuanhan 2009-03-31 08:39:07

well..it is very good example..but i would like to know more deeply bout how to set the timer from days, hours, minutes and second?


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month