SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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:

    Code:
    <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>
    Code:
    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') }
    });
    }
    Code:
    <?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.

  2. #2
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    w00ps, I forgot to say those are on 3 seperate files.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •