p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript (http://p2p.wrox.com/forumdisplay.php?f=85)
-   -   JavaScript Error (http://p2p.wrox.com/showthread.php?t=36592)

whiterainbow December 30th, 2005 04:00 AM

JavaScript Error
 
Hi,

I'm using the javascript to display the clock in my asp.net page. The script is given below:

<script type="text/javascript">
function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
// add a zero in front of numbers<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('dtime').innerHTML=h+":"+m +":"+s
t=setTimeout('startTime()',500)
}

function checkTime(i)
{
if (i<10)
  {i="0" + i}
  return i
}
</script>

I am calling the function on the body load event and providing the element to the table dimension (<td id="dtime">).

And I tried the element as div also(<div id="dtime">) but it is giving the nativecode writeups over there means the following is displayed in the div or td

function getHours() { [native code] } : function getMinutes() { [native code] } : function getSeconds() { [native code] }

And I tried to convert it into text and write over there still it is not displaying the clock. If anybody knows how to eliminate the native code write ups

Tnx n Regards

Thanks and Regards,

Senthil Kumar M.

senthilkumar.mohan@gmail.com
http://www.leanlearn.tk

joefawcett January 9th, 2006 04:10 AM

Are you sure you parentheses after the method calls?
e.g. do you have:
Code:

var h=today.getHours()
or
Code:

var h=today.getHours
--

Joe (Microsoft MVP - XML)


All times are GMT -4. The time now is 01:47 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.