473,394 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

digital clock

9
Hi: I am an retired school teacher who went back to school for the fun of it. my subjects were computer hardware. I am taking a course in javascript and it is about to get the better of me. I need some help with is this one. I got it to validate. But something is wrong with the logic maybe. It bombs out on object expected .
Please give me some input. thanks
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Digital Clock</title>
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
function curTime() {
var now = new date();
var day = now.GetDay();
var date = now.GetDate();
var year = now.GetFullYear();
var month = now.GetMonth();
var hours = now.GetHours() + 1;
var minutes = now.GetMinutes();
var seconds = now.GetSeconds();
var days = new Array();
days[0] = "Sunday"; days[1] = "Monday"; days[2] = "Tuesday";
days[3] = "Wednesday"; days[4] = "Thursday"; days[5] = "Friday";
days[6]="Saturday";
var display = days[day] + " " + month + "/" + date + "/"
+ year + " "+ hours + ":" + minutes + ":" + seconds;
document.forms[0].Readout.value = display;
}
var tick = setInterval("curTime()", 1000);
// STOP HIDING FROM INCOMPATIBLE BROWSERS --></script></head>
<body>
<form action="">
<p><input type="text" size="30" name="readout" /></p>
</form>
</body>
</html>
Nov 15 '06 #1
4 4994
Luongo
22
I doubt this will solve the problem, but make sure the cases are matching. Your input name is "readout" but you're calling it as "Readout".
Nov 15 '06 #2
Luongo
22
Furthermore, I believe you'll have to call the function when the page is loaded, ie body onLoad="CurDate()"... sorry I can't actually play around with it right now but I think that would be needed....
Nov 15 '06 #3
AricC
1,892 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. <!-- Adjust the placement of the clock in the line below -->
  2. <span id="pendule"></span>
  3. <script language="javascript" type="text/javascript">
  4. <!--
  5. function clock() {
  6. var digital = new Date();
  7. var hours = digital.getHours();
  8. var minutes = digital.getMinutes();
  9. var seconds = digital.getSeconds();
  10. var year = digital.getFullYear();
  11. var day = digital.getDay();
  12.  
  13. var month = new Array ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec")
  14. var day = new Array ("Sun","Mon","Tues","Wed","Thurs","Fri","Sat")
  15. var amOrPm = "AM";
  16. if (hours > 11) amOrPm = "PM";
  17. if (hours > 12) hours = hours - 12;
  18. if (hours == 0) hours = 12;
  19. if (minutes <= 9) minutes = "0" + minutes;
  20. if (seconds <= 9) seconds = "0" + seconds;
  21. dispTime = day[digital.getDay()] + "." + " " + month[digital.getMonth()] + " " + digital.getDate() + "," + " " + year + " ";
  22. dispTime = dispTime + hours + ":" + minutes + ":" + seconds + " " + amOrPm;
  23. document.getElementById('pendule').innerHTML = dispTime;
  24. setTimeout("clock()", 1000);
  25. }
  26. window.onload=clock;
  27. // -->
  28. </script>
Nov 15 '06 #4
AricC
1,892 Expert 1GB
Sorry missed the Edit timeout. This is one I've used for quite some time if need be I can make yours work, but nosense re-inventing the wheel.


HTH,
Aric
Nov 15 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: melanieab | last post by:
Hi again, I'm trying to draw a digital clock in the corner of a picturebox whenever a particular tabpage is in focus. I either need to be able to make the clock keep real time (I can get it to...
5
by: biltz | last post by:
hey...wanna source code of...digital clock by using nested for loop..if anybody know plzzzzzzzzzz...help me...i m getting eror in it..not sure wt do ....:(
24
by: mohsinalishah444 | last post by:
Dear All, PLZ TELL ME THE SOURCE CODE OF DIGITAL CLOCK IN C LANGUAGE . I REALLY NEED IT AND I DONOT KNOW HOW TO USE C LANGUAGE . ACTUALLY I WANT TO MAKE A CLOCK IN LINUX >IF ANY BODY POST ME THE...
10
by: novuseden | last post by:
i need to make a digital clock for my computer class that looks like this http://pheatt.emporia.edu/courses/2007/cs220f07/assignment04/assignment04.htm plz help
4
by: aakriti | last post by:
how to make a digital clock from using code of java,
10
by: merooo0ooo | last post by:
HELLO how are u all ? i want to do digital clock applet may be it's very stubid qez but i'm still biggener in java and i want to any one learn me how i can used thread to do digital clock but...
6
Parul Bagadia
by: Parul Bagadia | last post by:
Hi all, I want to make a digital clock in ActiveX DLL... any components ofr that? As such in VB we have to use all in-built tools... How do we add an AcitveX DLL in other VB applications?.. I...
1
by: ANB8503 | last post by:
Hello, I have created the below script; however, it's not showing in the box like it should... Help please!! I am running out of time to submit this assignment! Thanks in advance!! ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.