Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
172
rated 0 times [  176] [ 4]  / answers: 1 / hits: 21173  / 10 Years ago, tue, june 17, 2014, 12:00:00

I am getting this error while trying to set up a counter which calculates the total time taken to fill a particular form .Have tried the following things,



//script


var timeStart;
var timeStop;

$(document).load(function() {
timeStart = new Date();
});

$('#form_3').on('submit', function() {
timeStop = Math.round((timeStart.getTime() - new Date().getTime()) / 1000);
console.debug('time taken from load till submit: ' + timeStop);
});


//script



now getting error uncaught TypeError:Cannot read property 'getTime' of undefined.


More From » jquery

 Answers
12

May be you can try (new Date()).getTime()):



timeStop = Math.round((timeStart.getTime() - (new Date()).getTime()) / 1000);

[#70539] Sunday, June 15, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brennonr

Total Points: 124
Total Questions: 101
Total Answers: 101

Location: Estonia
Member since Wed, Jun 8, 2022
2 Years ago
;