[Answered ]-Django and jQuery: timing

2👍

You’ve almost got it. Keep value empty initially, and then set it in your jQuery submit callback.

$(document).ready(function()
{
    var start = new Date().getTime();
    $('#myform').submit(function(){
        var elapsed = new Date().getTime() - start;
        // set the value for time when the form is submitted
        $('#myform input[name="time"]').val(elapsed);
    });
});

Leave a comment