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...
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...
Code:
<html>
<head>
<title>Command Central</title>
<style type="text/css">
body {background-color:black}
h1 {color:yellow;text-align:center}
p {color:yellow}
th {color:yellow}
td {color:yellow}
</style>
<script type="text/javascript">
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toUTCString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
function checkCommand() {
var command=document.getElementsByTagName('textcommand').innerHTML;
if (command="add todo") {
addToDo();
}
}
function startTime() {
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
m=checkTime(m);
s=checkTime(s);
if (h>12) {
h=h-12;
document.getElementById('time').innerHTML=h+":"+m+":"+s+" PM";
}
else {
document.getElementById('time').innerHTML=h+":"+m+":"+s+" AM";
}
t=setTimeout('startTime()',500);
}
function checkTime(i) {
if (i<10) {
i="0" + i;
}
return i;
}
function myDate() {
var d=new Date();
var year=d.getFullYear();
var month=d.getMonth()+1;
var date=d.getDate();
document.getElementById('date').innerHTML=month+"/"+date+"/"+year;
}
var toDoArray[];
function addToDo() {
var input=prompt("Type what you want to add to the To-Do list.","Make it short please!");
toDoArray.push(input);
document.GetElementById('todo').innerHTML=toDoArray.toString();
}
</script>
</head>
<body onload="startTime();myDate()">
<h1><ins>Command Central</ins></h1>
<hr />
<br />
<table border="1" align="center">
<tr>
<th>Time</th>
<th>Date</th>
</tr>
<tr>
<td id="time"></td>
<td id="date"></td>
</tr>
</table>
<br />
<table border="4" align="center" bgcolor="yellow">
<tr>
<th style="color:black">To-Do</th>
</tr>
<tr>
<td id="todo" style="color:black"></td>
</tr>
</table>
<p style="text-align:center"><form><input type="text" name="textcommand" /><input type="button" value="Command!" name="command" onClick="checkCommand()" /></form></p>
</body>
</html>
Comment