Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to Javascript

Status
Not open for further replies.

GRIFFIJ

Programmer
Aug 29, 2002
43
GB
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
 
You have quite a few errors in your code, but primarily, your function is never being run because your script tags are wrong. The last / causes the browser to not run the code as JS.

Code:
<script type="text/javascript[COLOR=#FCE94F][highlight #A40000]/[/highlight][/color]">cdtd(); </script>

Remove it in both cases, and you'll start getting the rest of the errors.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Thank you very much most appreciated it worked now I have figure out how to format it with CSS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top