Countdown Check Question

Hello all!

So, I’m trying to create a countdown timer, that when it counts down, it resets, which I have gotten to work nicely while testing it. Now, I’m just having problems with some javascript checks to see if a timer is already running, or if you choose a different timer so it can cancel the last one and start the new one.

I am Using Prototype btw.

Currently I have:


<div id="timed">

</div>
<div id="text">
TEXT SHOWS HERE
</div>
<a href="#" onclick="Send('10', 'test1');return false;">Link 1</a>
<a href="#" onclick="Send('15', 'test2');return false;">Link 2</a>


function countdown(t, te) {




$('timed').innerHTML = t;

if (t == 0) {

$('text').innerHTML = 'test';
Work(10,te);
return;
}

t--;
c = setTimeout("countdown('"+t+"', '"+te+"')", 1000);
}



function Send(seconds, text) {
new Ajax.Request('Working.php',
{
method: 'post',
parameters: {seconds: seconds, Text: Text},
onSuccess: function(t) {
eval(t.responseText);

                },
onFailure: function() { alert('Error') }
});
}


<?php

require_once('db.inc.php');

session_start();

$current = time();
$time = $_POST['seconds'];
$reset = 10;
$timer = $current + $time;
$text = $_POST['Text'];
$countdown = $timer - $current;




?>

var current = '<?php echo $current; ?>';
var time = '<?php echo $countdown; ?>';
var text = '<?php echo $text; ?>';
var title = item;


countdown(time, text);



$('timed').title = current;

Thanks for you time in reading this and for the help in advance. :slight_smile:

w00ps, I forgot to say those are on 3 seperate files.