cat_evilness
11-24-2002, 12:54 PM
Hey guys,
Does anyone know how I could adapt the code below so that I can have more than 1 count down?
It's probably really easy but everything I have tried comes up with errors.
<html>
<head>
<script language="javascript">
<!--
var countdownValue='10';
function countdownScript(){
if(countdownValue>=10){
countdownValue=10
}
countdown.innerHTML=countdownValue;
if(countdownValue<=0){
clearTimeout(Timer)
}
else{
countdownValue--;
Timer=setTimeout("countdownScript();", 3000);
}
}
function hmm(){
clearTimeout(Timer)
countdownValue+=2
countdownScript()
}
onload=countdownScript
//-->
</script>
<title>Virtual Pet - Version 1.0</title>
</head>
<body bgcolor="#FF9900" text="#ffff99" link="#00ff00" alink="#ffa500" vlink="#ff0000">
<basefont size="3">
<table width="220" valign="top" border="0">
<tr>
<td width="180" bgcolor="#000000" valign="left" align="left" border="0">
Mood:</br>
</td>
<td width="40" bgcolor="#000000" valign="left" align="left" border="0">
<span id="countdown"></span></br>
</td>
</tr>
</table>
<form name=f1>
<input type="button" value="Button" onclick="hmm()">
</form>
</body>
</html>
Thankyou,
Cat
Does anyone know how I could adapt the code below so that I can have more than 1 count down?
It's probably really easy but everything I have tried comes up with errors.
<html>
<head>
<script language="javascript">
<!--
var countdownValue='10';
function countdownScript(){
if(countdownValue>=10){
countdownValue=10
}
countdown.innerHTML=countdownValue;
if(countdownValue<=0){
clearTimeout(Timer)
}
else{
countdownValue--;
Timer=setTimeout("countdownScript();", 3000);
}
}
function hmm(){
clearTimeout(Timer)
countdownValue+=2
countdownScript()
}
onload=countdownScript
//-->
</script>
<title>Virtual Pet - Version 1.0</title>
</head>
<body bgcolor="#FF9900" text="#ffff99" link="#00ff00" alink="#ffa500" vlink="#ff0000">
<basefont size="3">
<table width="220" valign="top" border="0">
<tr>
<td width="180" bgcolor="#000000" valign="left" align="left" border="0">
Mood:</br>
</td>
<td width="40" bgcolor="#000000" valign="left" align="left" border="0">
<span id="countdown"></span></br>
</td>
</tr>
</table>
<form name=f1>
<input type="button" value="Button" onclick="hmm()">
</form>
</body>
</html>
Thankyou,
Cat