Search code examples
phpjavascriptmysqltimestopwatch

Capturing final stopwatch time


I want to use this stopwatch (or something similar):

http://www.sivamdesign.com/scripts/dwld/stopwtch.txt

but I will need to capture the final time that it is stopped on, and then store it as a variable (so I can later add it into a database). Is it possible to capture the time as a variable?

Thanks for any help


Solution

  • If you're using the script you provided, you can access the final time via

    document.clock.stwa.value
    

    or to get the parts, you can access the vars sec, min and hour.

    What are you planning on doing with the final time?

    Edit: Then you can either post the value via AJAX or just throw form tags around the value textbox and add a submit button (or submit the value when user hits "Stop"). To start on page load, add this:

    window.onload = function()
    {
      stopwatch('Start');
    }