Hi I am new to JavaScript and I am trying to put a countdown clock on my website I have written the code and it says that the code is correct however when I run it all I get is a blank screen and no countdown clock not sure why.
Code:
<html>
<head>
<script type="text/javascript/">
function cdtd () {
var disney = new Date("August 25, 2015 00:00:00");
var now = new Date ();
var timeDiff = disney.getTime() - now.getTime();
var seconds = Math.floor(timeDiff / 1000);
var minutes = Math.floor(seconds / 60);
var hours = Math.floor(minutes / 60);
var days = Math.floor(hours / 24);
document.getElementById("DaysBox").innerHTML = days;
document.getElementById("HoursBox").innerHTML = hours;
document.getElementById("MinutesBox").innerHTML = minutes;
document.getElementById("SecondsBox").innerHTML = seconds;
var timer=setTimeout ('cdtd()',1000);
}
</script>
</head>
<body>
<div id="daysBox"></div>
<div id="hoursBox"></div>
<div id="minsBox"></div>
<div id="secsBox"></div>
<script type="text/javascript/">cdtd(); </script>
</body>
</html>
Thank You Joel
Code:
<html>
<head>
<script type="text/javascript/">
function cdtd () {
var disney = new Date("August 25, 2015 00:00:00");
var now = new Date ();
var timeDiff = disney.getTime() - now.getTime();
var seconds = Math.floor(timeDiff / 1000);
var minutes = Math.floor(seconds / 60);
var hours = Math.floor(minutes / 60);
var days = Math.floor(hours / 24);
document.getElementById("DaysBox").innerHTML = days;
document.getElementById("HoursBox").innerHTML = hours;
document.getElementById("MinutesBox").innerHTML = minutes;
document.getElementById("SecondsBox").innerHTML = seconds;
var timer=setTimeout ('cdtd()',1000);
}
</script>
</head>
<body>
<div id="daysBox"></div>
<div id="hoursBox"></div>
<div id="minsBox"></div>
<div id="secsBox"></div>
<script type="text/javascript/">cdtd(); </script>
</body>
</html>
Thank You Joel