Column Adding (JQuery)

language: jQuery (JavaScript)
license: Other

Code for Snippet:

$(document).ready(function() {
  $('#table input').keyup(function() {
function calculateTotals() {
  var numberOfColumns = $('#table tr:first input').length;
  for (var i=0; i<numberOfColumns; i++) {
    var values = $.map($('#report tr:not(.results)'), function(row) {
      return $(row).find('input').eq(i).val().replace(/[^0-9.]/g, '');
    var sum = 0;
    $.each(values, function() { sum += Number(this) });
    $('#table tr:last').eq(i).html(sum);
comments powered by Disqus


Link to this snippet:

Download to Code Collector

To use the direct link to your snippet on either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 319
Date Added: 2009-08-15 11:45:05
Last Modified: 0000-00-00 00:00:00

Web Analytics