»
EnglishFrenchVietnamese

Print - Two More Clocks - JavaScriptBank.com

Full version: jsB@nk » Time » Clock » Two More Clocks
URL: http://www.javascriptbank.com/two-more-clocks.html

Two More Clocks © JavaScriptBank.comThis JavaScript creates two more clocks.

Full version: jsB@nk » Time » Clock » Two More Clocks
URL: http://www.javascriptbank.com/two-more-clocks.html



JavaScript
<SCRIPT language=JavaScript><!--var timerID = nullvar timerRunning = falsefunction stopclock(){    if(timerRunning)        clearTimeout(timerID)    timerRunning = false}function startclock(){    stopclock()    showtime()}function showtime(){    var now = new Date()    var hours = now.getHours()    var minutes = now.getMinutes()    var seconds = now.getSeconds()    var timeValue = "" + ((hours > 12) ? hours - 12 : hours)    timeValue  += ((minutes < 10) ? ":0" : ":") + minutes    timeValue  += ((seconds < 10) ? ":0" : ":") + seconds    timeValue  += (hours >= 12) ? " P.M." : " A.M."    document.clock.face.value = timeValue    timerID = setTimeout("showtime()",1000)    timerRunning = true}//--></SCRIPT><SCRIPT language=JavaScript><!--Hide JavaScript from Java-Impaired Browsersvar isn1 = null;var isn2 = false;today=new Date();function stopit(){    if(isn2){        clearTimeout(isn1);        }    isn2 = false;    }function startit(){    stopit();    isnclock();    }function isnclock(){    var now = new Date()    var hrs = now.getHours()    var min = now.getMinutes()    var sec = now.getSeconds()    document.clckh.disp.value = "" + ((hrs > 12) ? hrs - 12 : hrs)     document.clckm.disp.value = ((min < 10) ? "0" : "") + min    document.clcks.disp.value = ((sec < 10) ? "0" : "") + sec    document.clck.disp.value = (hrs >= 12) ? "p.m." : "a.m."    isn1 = setTimeout("isnclock()",1000)    isn2 = true}// Build an array initializerfunction isnArray() {  argnr = isnArray.arguments.length  for (var i = 0; i < argnr; i++)  this[i+1] = isnArray.arguments[i]  }// And months and day arraysvar isnMonths= new isnArray("January","February","March","April","May","June","July","August","September","October","November","December");//--></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<BODY onload=startit()><FORM method=post><A onmouseover="window.status='Click me to start the clock!'; return true" onmouseout="window.status=''; return true;" href="javascript:startclock()">Click here to start</A></FORM><FORM name=clock onsubmit=0 method=post><INPUT size=12 value="Press Start         (WebClock)" name=face></FORM><FORM method=post><A onmouseover="window.status='Click me to stop the clock!'; return true" onmouseout="window.status=''; return true;" href="javascript:stopclock()">Click here to stop</A> </FORM><TABLE border=2>  <TBODY>  <TR>    <TD><B>Time</B></TD>    <TD>Hour</TD>    <TD>Min</TD>    <TD>Sec</TD>    <TD></TD></TR>  <TR>    <TD></TD>    <TD vAlign=top>      <FORM name=clckh onsubmit=0><INPUT size=2 name=disp> </FORM></TD>    <TD vAlign=top>      <FORM name=clckm onsubmit=0><INPUT size=2 name=disp> </FORM></TD>    <TD vAlign=top>      <FORM name=clcks onsubmit=0><INPUT size=2 name=disp> </FORM></TD>    <TD vAlign=top>      <FORM name=clck onsubmit=0><INPUT size=4 name=disp> </FORM></TD></TR>  <SCRIPT language=JavaScript><!--Hide JavaScript from Java-Impaired Browsers  document.write("<TR><TD><B>Date</B></TD><TD COLSPAN=4>"   + isnMonths[today.getMonth() + 1]    + " " + today.getDate() + ", " + today.getYear());// Finish hiding of script -->  </SCRIPT>  </TD></TR></TBODY></TABLE></body><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->