http://jsfiddle.net/zAFND/640/
In jsfiddle I have, what I am having issue with is the response time. It is going up by 2 seconds rather than 1 second. I believe the issue with this is because I have 2 questions so it counts the seconds for both questions in each response time text input and hence it goes up by 2 seconds each time. But my question is how to sort this out so timer is counting up normally:
Code for response time:
`
var response = “00:00:00”,
responseparts = response.split(‘:’),
responsehours = +responseparts[0],
responseminutes = +responseparts[1],
responseseconds = +responseparts[2];
function correctResponse(responsenum) {
return (responsenum < 10) ? ("0" + responsenum) : responsenum;
}
var responsetimer = [];
$('.queWrap').each(function(index, element) {
var wrap=$(this),
input = wrap.find('.responseTime'),
checkbox=wrap.find('#ck-button').find('input'),
clickInput=wrap.find('.mouseClick');
responsetimer[index] = setInterval(function () {
responseseconds++;
if (responseseconds == 60) {
responseseconds = 00;
responseminutes++;
if (responseminutes == 60) {
responseminutes = 00;
responsehours++;
if (responsehours <= 24) {
clearInterval(responsetimer);
return;
}
}
}
input.val(correctResponse(responsehours) + ":" + correctResponse(responseminutes) + ":" + correctResponse(responseseconds));
}, 1000);
`
Move the var declarations for
inside the each callback
http://jsfiddle.net/h8srH/1/
Also, change your ck-button id’s to classes. Id’s are meant to be unique.