Click to See Complete Forum and Search --> : Anybody know why thisa isn't working????


DJRobThaMan
11-09-2003, 03:58 PM
I can't seem to find anything really wrong with this code but for some reason it just won't work. Anybody have any ideas?

<html>
<head>
<title>
STOP WATCH
</title>
<script type="text/javascript">
<!--

var l = 0;
var i = 0;
var j = 0;
var k = 0;

function timer(){

i = ((i + 1)%10);

if(i == 0){

j = ((j+1)%6);
++l;
}

if(j == 0){
if(l > 1){
if(i == 0){
++k;
}
}
}



document.getElementById("clock").style.innerHTML = eval('k') + ":" + eval('j') + eval('i');
}

function start(){
time = setInterval('timer()',100);
}

function stop(){
clearInterval(time);
}

-->
</script>
</head>
<body>
<div id="clock">
</div>
<BR>
<input type="button" value="Start Timer" onClick="start()">
<input type="button" value="Stop Timer" onClick="stop()">
</body>
</html>

Thanks

fredmv
11-09-2003, 04:41 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>untitled</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<script type="text/javascript">
//<![CDATA[
var l = 0, i = 0, j = 0, k = 0;

function timer()
{
i = ((i + 1)%10);

if(i == 0)
{
j = ((j+1)%6);
++l;
}

if(j == 0 || l > 1 || i == 0) ++k;

document.getElementById("clock").innerHTML = k + ":" + j + "" + i;
}

function start()
{
time = setInterval(timer, 100);
}

function stop()
{
clearInterval(time);
}
//]]>
</script>
</head>
<body>
<form action="#">
<div>
<div id="clock"></div>
<input type="button" value="Start Timer" onclick="start();" />
<input type="button" value="Stop Timer" onclick="stop();" />
</div>
</form>
</body>
</html>