replied on September 8, 2014
Here is a screen shot of the form with the class identifiers and script. The class for the radio buttons is difficult to read but they are timeSTARTTOD and timeENDTOD
$(document).ready(function () {
$('.cf-table-block').on('blur', 'input', sumtotal);
function sumtotal() {
var total1 = 0;
var total2 = 0;
var total3 = 0;
$('.cf-table-block tbody tr').each(function () {
var s = 0;
var timeS = 0;
var timeE = 0;
$(this).find('.timeSTART input').each(function () {
timeS = parseNumber($(this).val());
});
$(this).find('.timeEND input').each(function () {
timeE = parseNumber($(this).val());
});
s = timeE - timeS;
$(this).find('.subtotal input').val(s);
if ($(this).find('.timeTYPE option:selected').val() === "Type1"){
total1 += s;
}
else if ($(this).find('.timeTYPE option:selected').val() === "Type2"){
total2 += s;
}
else if ($(this).find('.timeTYPE option:selected').val() === "Type3"){
total3 += s;
}
$('.totalTYPE1 input').val(total1);
$('.totalTYPE2 input').val(total2);
$('.totalTYPE3 input').val(total3);
});
}
function parseNumber(n) {
var f = parseFloat(n); //Convert to float number.
return isNaN(f) ? 0 : f; //treat invalid input as 0;
}
});
