So the issue I'm running into is I'll have a row in a table highlighted when a value is over "0", then when the form is submitted it loses the highlighting until you select the field again. I know I have it set up so the function runs when that happens but I need it to keep the formatting throughout the whole process. Here is my code.
$(document).ready(function() {
setTimeout(function(){
$('body').addClass('loaded');
}, 3000);
$('.cf-table-block').on('blur', 'input', highlight);
function highlight(){
$('.cf-table-block tbody tr').each(function(){
var t1 = 0;
var t2 = 0;
var t3 = 0;
var t4 = 0;
var t5 = 0;
var t6 = 0;
var t7 = 0;
var t8 = 0;
var t9 = 0;
var t10 = 0;
var t11 = 0;
var t12 = 0;
var t13 = 0;
t1 = parseNumber($(this).find('.total1 input').val());
t2 = parseNumber($(this).find('.total2 input').val());
t3 = parseNumber($(this).find('.total3 input').val());
t4 = parseNumber($(this).find('.total4 input').val());
t5 = parseNumber($(this).find('.total5 input').val());
t6 = parseNumber($(this).find('.total6 input').val());
t7 = parseNumber($(this).find('.total7 input').val());
t8 = parseNumber($(this).find('.total8 input').val());
t9 = parseNumber($(this).find('.total9 input').val());
t10 = parseNumber($(this).find('.total10 input').val());
t11 = parseNumber($(this).find('.total11 input').val());
t12 = parseNumber($(this).find('.total12 input').val());
t13 = parseNumber($(this).find('.total13 input').val());
if (t1 > 0) {
$(this).closest('tr').css("background", "yellow");
}
else if (t2 > 0){
$(this).closest('tr').css("background", "yellow");
}
else if (t3 > 0) {
$(this).closest('tr').css("background", "yellow");
}
else if (t4 > 0){
$(this).closest('tr').css("background", "yellow");
}
else if (t5 > 0) {
$(this).closest('tr').css("background", "yellow");
}
else if (t6 > 0){
$(this).closest('tr').css("background", "yellow");
}
else if (t7 > 0) {
$(this).closest('tr').css("background", "yellow");
}
else if (t8 > 0){
$(this).closest('tr').css("background", "yellow");
}
else if (t9 > 0) {
$(this).closest('tr').css("background", "yellow");
}
else if (t10 > 0){
$(this).closest('tr').css("background", "yellow");
}
else if (t11 > 0) {
$(this).closest('tr').css("background", "yellow");
}
else if (t12 > 0){
$(this).closest('tr').css("background", "yellow");
}
else if (t13 > 0) {
$(this).closest('tr').css("background", "yellow");
}
else if (t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13 == 0){
$(this).closest('tr').css("background", "none");
}
});
}
function parseNumber(n){
var f = parseFloat(n);
return isNaN(f) ? 0 : f;
}
});
I'm including a screenshot of the highlighting in action.