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!

Javascript and CSS 1

Status
Not open for further replies.

GRIFFIJ

Programmer
Aug 29, 2002
43
GB
Hi I have created a countdown clock in JavaScript Now I want to put that clock into a Div tag and format it but unsure how can anyone help?

Code

<!doctype html>
<html>
<head>
<script type="text/javascript">
function cdtd ()

{
var disney = new Date("August 25, 2015 03: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);

hours %= 24;
minutes %= 60;
seconds%= 60;

document.getElementById("daysBox").innerHTML = days;
document.getElementById("hoursBox").innerHTML = hours;
document.getElementById("minsBox").innerHTML = minutes;
document.getElementById("secsBox").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>

Thanks Joel
 
Your code is already in DIVS.
Code:
<div id="daysBox"></div>
<div id="hoursBox"></div>
<div id="minsBox"></div>
<div id="secsBox"></div>


Formatting would be done via CSS by applying it to your Divs. what exactly do you want the end product to look like?

----------------------------------
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top