Display a DIGITAL CLOCK on the WebBrowser

Abhisek
Posted by Abhisek under JavaScript category on | Views : 4521
The following JavaScript will display a Digital Clock on the web browser.

<html>
<head>
<title>DIGITAL CLOCK
</title>
</head>
<body>
<TABLE BORDER=4 BGCOLOR=PURPLE>
<TR>
<TD>
<FORM NAME="clock_form">
<INPUT TYPE=TEXT NAME="digitalclock"SIZE=32>
</FORM>
<SCRIPT LANGUAGE="JavaScript">
function clockTick()
{
currentTime = new Date();
//displaying the clock and appending current date and time.
document.clock_form.digitalclock.value = ""+currentTime;
document.clock_form.digitalclock.blur();
SetTimeout("clockTick()",1000);
}
clockTick();
//End of java script functions
</SCRIPT>
</TD>
</TR>
</TABLE>
</body>
</html>

Comments or Responses

Posted by: Poster on: 11/7/2009 Level:Starter | Status: [Member]
Your code snippet is not working, here is the modified and working version of Javascript code

<SCRIPT LANGUAGE="JavaScript">

function clockTick()
{
currentTime = new Date();
document.clock_form.digitalclock.value = currentTime;
document.clock_form.digitalclock.blur();
setTimeout("clockTick()",1000);
}
clockTick();
//End of java script functions
</SCRIPT>


Thanks
Posted by: Abhisek on: 11/7/2009 Level:Bronze | Status: [Member]
Hi, Poster

The code is working correctly. I have checked. The time and date are being displayed.

Login to post response