So I just started learning HTML and Javascript about a week ago, and while I'm writing this code, I get an error saying "Object Required". I don't understand why the object is required, and how to fix it, so could you please help?
Also, I probably have other errors as well, so if you could suggest any other corrections to my code, that would be great!
The error states that the object is required on line 2, character 1.
The following code is all the Javascript code I have in the head section of my HTML document so far...
Thanks!!!
Also, I probably have other errors as well, so if you could suggest any other corrections to my code, that would be great!
The error states that the object is required on line 2, character 1.
The following code is all the Javascript code I have in the head section of my HTML document so far...
Code:
<script type="text/javascript">
var command=document.getElementById('tc').innerHTML;
function checkCommand() {
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);
document.getElementById('time').innerHTML=h+":"+m+":"+s;
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;
}
function addToDo() {
var input=prompt("Type what you need To-Do...","Make it short please!");
var tdv=document.getElementById('todo').innerHTML;
if (tdv.length>0) {
tdv=tdv+"<br />"+input;
}
else {
tdv=input;
}
}
</script>
Comment