Count Down - Submit button

Discussion in 'JavaScript' started by redbayron2006, Apr 13, 2010.

  1. #1
    Hi there to all,

    I have the following problem:
    I want to extract a timestamp (a) from a mysql database (future value) and display a countdown timer (minutes and secs) in a box from the present timestamp (b).

    When the countdown reach zero I want a msg to be displayed along with a submit button in the browser and a new function fired that will set the timestamp (a) to zero in the mysql database.

    Can anybody give me some hints of code here? thanks in advance!
     
    redbayron2006, Apr 13, 2010 IP
  2. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You should use AJAX to get the timestamp without refreshing the page and when the AJAX's onReadyState == 4; you use document.getElementById() to populate a div with the value of a count down function (SetInterval()) and then have another script compare the countdown with the AJAX response (your timestamp) and if it == 0 then send another AJAX request to the server inputing the new timestamp.

    Well that's how I would do it. Hope it helps!

    ~imozeb
     
    Imozeb, Apr 13, 2010 IP