function totalByIndex(selector, prevUntil, prevAll) {
$(selector).each(function(){
- var subtot = 0;
- var i = $(this).index();
- if (prevUntil !== undefined && prevUntil !== null && prevUntil !== false) {
- var prevs = $(this).parent('tr').prevUntil(prevUntil);
- } else if (prevAll !== undefined && prevAll !== null && prevAll !== false) {
- var prevs = $(this).parent('tr').prevAll(prevAll);
- }
- prevs.each(function(){
- var cell = $($(this).children('td')[i]);
- var val;
- if (cell.children('input').length == 1) {
- val = cell.children('input').val();
- } else {
- val = cell.html();
+ var subtot = 0;
+ var i = $(this).index();
+ if (prevUntil !== undefined && prevUntil !== null && prevUntil !== false) {
+ var prevs = $(this).parent('tr').prevUntil(prevUntil);
+ } else if (prevAll !== undefined && prevAll !== null && prevAll !== false) {
+ var prevs = $(this).parent('tr').prevAll(prevAll);
}
- subtot += clean_float(val);
- });
- $(this).html(subtot);
+ prevs.each(function(){
+ var cell = $($(this).children('td')[i]);
+ var val;
+ if (cell.children('input').length == 1) {
+ val = cell.children('input').val();
+ } else {
+ val = cell.html();
+ }
+ subtot += clean_float(val);
+ });
+ $(this).html(subtot);
});
}