Debt Consolidation - Find jobs - Debt Consolidation - Self Improvement Articles Directory - Payday Loans

PDA

View Full Version : Javascript - need my clock validated


littleme
Nov 16th 2006, 6:03 am
i have tryed to validate this code ( at validator.w3.org) many times and everytime i get this error. can anybody tell me what i have to change to get it to work?
:confused:

1. Error Line 80 column 14: document type does not allow element "SPAN" here; missing one of "P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag.

<span id="txt"> </span>

The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
<title> bunn
</title>
</head>
<body onload="startTime()">
<script type="text/javascript">

<!--

// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Søndag','Mandag','Tirsdag','Onsdag','Torsdag','Fredag','Lørdag');

// Array list of months.
var months = new Array('Januar','Februar','Mars','April','Mai','Juni','Juli','August','September','Oktober','November','Desember');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;
}

// Join it all together
today = days[now.getDay()] + " " +
date + ". " +
months[now.getMonth()] + " " +
(fourdigits(now.getYear()));

// Print out the data

document.write("Lokal tid: " +today+ " ");
document.write("kl.");
// End -->
</script>

<script type="text/javascript">
<!--
function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
// add a zero in front of numbers<10

var siffer = "";

if( h < 10 ) {
siffer = "0"
}

m=checkTime(m)
s=checkTime(s)
document.getElementById("txt").innerHTML= siffer + h +":"+m+":"+s
t=setTimeout('startTime()',500)
}

function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}
//-->
</script>

<span id="txt"> </span>

</body>
</html>

SoKickIt
Nov 16th 2006, 6:15 am
i have tryed to validate this code ( at validator.w3.org) many times and everytime i get this error. can anybody tell me what i have to change to get it to work?
:confused:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
<title> bunn
</title>
</head>
<body onload="startTime()">
<script type="text/javascript">

<!--

// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Søndag','Mandag','Tirsdag','Onsdag','Torsdag','Fredag','Lørdag');

// Array list of months.
var months = new Array('Januar','Februar','Mars','April','Mai','Juni','Juli','August','September','Oktober','November','Desember');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;
}

// Join it all together
today = days[now.getDay()] + " " +
date + ". " +
months[now.getMonth()] + " " +
(fourdigits(now.getYear()));

// Print out the data

document.write("Lokal tid: " +today+ " ");
document.write("kl.");
// End -->
</script>

<script type="text/javascript">
<!--
function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
// add a zero in front of numbers<10

var siffer = "";

if( h < 10 ) {
siffer = "0"
}

m=checkTime(m)
s=checkTime(s)
document.getElementById("txt").innerHTML= siffer + h +":"+m+":"+s
t=setTimeout('startTime()',500)
}

function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}
//-->
</script>

<div><span id="txt"> </span></div>

</body>
</html>

littleme
Nov 16th 2006, 6:27 am
well, thanx for the help but the date and the watch has to be on only one line.