I am currently using 2 time fields and a jquery script to find the difference between the two.
function timediff() {
var end_time = $('.EndTime input').val();
var start_time = $('.StartTime input').val();
var diff = ( new Date("1970-1-1 " + end_time) - new Date("1970-1-1 " + start_time) ) / 1000 / 60 / 60;
$(".JavaNum input").val(diff);
}
$('.EndTime').on('change', function () {
timediff();
});
I am now trying to do the same thing but in a table:
However the code I am using doesn't seem to working. Any input on what I could possibly be doing wrong here?
$(document).ready(function () {
$('.cf-table-block').on('blur', 'input', tablediff);
function tablediff() {
$('.cf-table-block tbody tr').each(function () {
var end_time = $(this).find('timeout input').val();
var start_time = $(this).find('timein input').val();
var interrupt = $(this).find('interupt input').val();
var totaltime = ( new Date("1970-1-1 " + end_time) - new Date("1970-1-1 " + start_time) ) / 1000 / 60 / 60;
$(this).find('totalhour input').val(totaltime);
});
}
});