html - Javascript Interval not repeating -


i have setinterval in html/javascript document. now, far aware, setinterval part typed out in document of mine, , works there. in interval not repeating every 1 second. runs once, stops. there blatant errors missing?

<html> <head> <title>time</title> </head> <body>  <p id="line-one" /> <p id="line-two" /> <p id="line-three" /> <p id="line-four" /> <p id="seconds" />      <script type='text/javascript'language='javascript'>  var = new date(); var hour = now.gethours(); var minute = now.getminutes(); var second = now.getseconds(); var nintervid;  function counter() {        if (typeof(nintervid) != "undefined") {         clearinterval(nintervid);     }      nintervid = setinterval(changeascii, 1000); }  function changeascii() {     document.getelementbyid("seconds").innerhtml = second;     switch(second) {         case 00:         document.getelementbyid("line-one").innerhtml = " ___...___ ";         document.getelementbyid("line-two").innerhtml = "|...|.|...|";         document.getelementbyid("line-three").innerhtml = "|.|.|.|.|.|";         document.getelementbyid("line-four").innerhtml = "|___|.|___|";         break;         case 01:         document.getelementbyid("line-one").innerhtml = " ___   ___";         document.getelementbyid("line-two").innerhtml = "|   | |_  |";         document.getelementbyid("line-three").innerhtml = "| | |  _| |_";         document.getelementbyid("line-four").innerhtml = "|___| |_____|";         break;         default:         document.getelementbyid("line-one").innerhtml = "nothing";         document.getelementbyid("line-two").innerhtml = "to";         document.getelementbyid("line-three").innerhtml = "see";         document.getelementbyid("line-four").innerhtml = "here";         break;     } }   window.onload = counter();  </script> </body> </html> 

everything fine, although, not update real value of second hence date, not updated.

check out in fiddle;

http://jsfiddle.net/h8c4w/

function changeascii() {     now=new date();     second=now.getseconds(); ... 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -