473,382 Members | 1,583 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,382 software developers and data experts.

Time and Date will not show up!

I made a clock on my HTML document, and tried to make it show the current date. After I loaded the page, it worked fine.

However, after typing more code and testing things completely separate from the time and date, when I loaded the page awhile later, the time and date didn't show up. I never even touched the functions to display the time and date, yet they wouldn't show up on my document! I need to know why they wouldn't show up.

I will include errors to help you solve this problem for me. Be aware, I have not been doing this long (HTML and Javascript), only about a week. So it would be ideal if I got a descriptive answer to help me understand what's going on.

Thanks!!!

Errors: 1.Line:69
Char:14
Error: Expected ';'

2.Line:77
Char:1
Error:Object expected

By the way, I'm using Internet Explorer...

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Command Central</title>
  4. <style type="text/css">
  5. body {background-color:black}
  6. h1 {color:yellow;text-align:center}
  7. p {color:yellow}
  8. th {color:yellow}
  9. td {color:yellow}
  10. </style>
  11. <script type="text/javascript">
  12. function createCookie(name,value,days) {
  13.     if (days) {
  14.         var date = new Date();
  15.         date.setTime(date.getTime()+(days*24*60*60*1000));
  16.         var expires = "; expires="+date.toUTCString();
  17.     }
  18.     else var expires = "";
  19.     document.cookie = name+"="+value+expires+"; path=/";
  20. }
  21. function readCookie(name) {
  22.     var nameEQ = name + "=";
  23.     var ca = document.cookie.split(';');
  24.     for(var i=0;i < ca.length;i++) {
  25.         var c = ca[i];
  26.         while (c.charAt(0)==' ') c = c.substring(1,c.length);
  27.         if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  28.     }
  29.     return null;
  30. }
  31. function eraseCookie(name) {
  32.     createCookie(name,"",-1);
  33. }
  34. function checkCommand() {
  35.   var command=document.getElementsByTagName('textcommand').innerHTML;
  36.   if (command="add todo") {
  37.     addToDo();
  38.   }
  39. }
  40. function startTime()  {
  41.   var today=new Date();
  42.   var h=today.getHours();
  43.   var m=today.getMinutes();
  44.   var s=today.getSeconds();
  45.   m=checkTime(m);
  46.   s=checkTime(s);
  47.   if (h>12) {
  48.     h=h-12;
  49.     document.getElementById('time').innerHTML=h+":"+m+":"+s+" PM";
  50.   }
  51.   else {
  52.     document.getElementById('time').innerHTML=h+":"+m+":"+s+" AM";
  53.   }
  54.   t=setTimeout('startTime()',500);
  55. }
  56. function checkTime(i) {
  57.   if (i<10) {
  58.     i="0" + i;
  59.   }
  60.   return i;
  61. }
  62. function myDate() {
  63.   var d=new Date();
  64.   var year=d.getFullYear();
  65.   var month=d.getMonth()+1;
  66.   var date=d.getDate();
  67.   document.getElementById('date').innerHTML=month+"/"+date+"/"+year;
  68. }
  69. var toDoArray[];
  70. function addToDo() {
  71.   var input=prompt("Type what you want to add to the To-Do list.","Make it short please!");
  72.   toDoArray.push(input);
  73.   document.GetElementById('todo').innerHTML=toDoArray.toString();
  74. }
  75. </script>
  76. </head>
  77. <body onload="startTime();myDate()">
  78. <h1><ins>Command Central</ins></h1>
  79. <hr />
  80. <br />
  81. <table border="1" align="center">
  82. <tr>
  83.   <th>Time</th>
  84.   <th>Date</th>
  85. </tr>
  86. <tr>
  87.   <td id="time"></td>
  88.   <td id="date"></td>
  89. </tr>
  90. </table>
  91. <br />
  92. <table border="4" align="center" bgcolor="yellow">
  93. <tr>
  94.   <th style="color:black">To-Do</th>
  95. </tr>
  96. <tr>
  97.   <td id="todo" style="color:black"></td>
  98. </tr>
  99. </table>
  100. <p style="text-align:center"><form><input type="text" name="textcommand" /><input type="button" value="Command!" name="command" onClick="checkCommand()" /></form></p>
  101. </body>
  102. </html>
  103.  
May 4 '10 #1
2 1364
Dormilich
8,658 Expert Mod 8TB
var toDoArray[]; is invalid syntax. you probably mean var toDoArray = [];
May 5 '10 #2
Ahh yes, that was just a careless mistake! Thanks!
May 5 '10 #3

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

Similar topics

9
by: Steve Jorgensen | last post by:
Hi all, I'm working on the schema for a database that must represent data about stock & bond funds over time. My connundrum is that, for any of several dimension fields, including the fund name...
5
by: Gord | last post by:
Many scripts and calendars call client side system time in order to make presentations. However, the client's time may be improperly set, if set at all, and/or the relevant time may be from...
16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
9
by: Bob Achgill | last post by:
I would like to use the timestamp on files to manage the currency of support files for my VB windows application. In this case I would only put the timestamp of the file in the management database...
7
by: Brett Edman | last post by:
I created a UTC clock using this: UTCTime = MyTime.ToUniversalTime() Now that we've turned the clocks ahead 1 hour for daylight savings time, the clock is reporting the wrong UTC time. It is...
8
by: Dean | last post by:
Hi, I am using Vb.net and I want to know how to put the Time, Date which ticks?? Please reply as soon as possible Dean PS: Please make the answer simple because I am only 11 Yrs old and...
3
by: colleen1980 | last post by:
Hi: Data in my table is in that format. How to i separate date with time. 11/9/2006 10:10:46 AM Thank You.
1
by: Susan Bricker | last post by:
Greetings. I have a report (actually all of my reports in an MDB) that I want to date/time stamp at the bottom. Previously, I had used the builtin function of Now(). I thought that would give...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
11
by: xenoix | last post by:
hey there, im reasonably new to C# and im currently writing a backup application which im using as a learning resource. My PC :- Visual Studio 2005 .NET Framework 2 Component Factory Krypton...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.