home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Javascript / JavaScriptEditor / jse_en28.exe / %MAINDIR% / Tutorial / Counter.js < prev    next >
Encoding:
JavaScript  |  2001-09-10  |  758 b   |  32 lines

  1. //Little bit number counting.
  2.  
  3. var Num=1;
  4. var speed = 200;
  5. var Stopped=0;
  6.  
  7. function Counting() {
  8.   // to access a form object, 
  9.   // document.[FORMNAME].[OBJECTNAME].value=[whatever]    
  10.   document.counter.numbox.value=Num
  11.   Num++
  12.   if (Stopped == 0) { 
  13.     setTimeout("Counting()", speed); }
  14. }
  15.  
  16. function startCounting() {
  17.   Stopped = 0;             
  18.   Counting();
  19. }
  20.  
  21. function stopCounting() {
  22.   Stopped = 1;
  23. }
  24.  
  25. document.writeln("Test");
  26. document.writeln("<FORM NAME=counter>");
  27. document.writeln("<INPUT TYPE=\"TEXT\" NAME=\"numbox\" SIZE=\"5\">");
  28. document.writeln("<INPUT TYPE=BUTTON VALUE=START onClick=\"startCounting()\">");
  29. document.writeln("<INPUT TYPE=BUTTON VALUE=STOP onClick=\"stopCounting()\">");
  30. document.writeln("</FORM>");
  31.  
  32.