Skip to content

Instantly share code, notes, and snippets.

@iacutone
Created December 18, 2013 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iacutone/8025514 to your computer and use it in GitHub Desktop.
Save iacutone/8025514 to your computer and use it in GitHub Desktop.
function removeCommas(str) {
return(str.replace(/,/g,''));
}
filterInt = function (value) {
if(/^\-?([0-9]+|Infinity)$/.test(value))
return Number(value);
return NaN;
}
$('tr').each(function() {
var values = $(this).find('td').map(function() {
return $(this).text();
}).get();
var total = 0;
var items = [];
for(var i = 0; i < values.length; i++) {
value = parseInt(removeCommas(values[i]));
if (!isNaN(value)){
console.log(value);
total += value;
items.push(total);
if(items.length == 7){
$(this).find('td:eq(7)').append(items[6]);
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment