Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 930483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:20:33+00:00 2026-05-15T20:20:33+00:00

I have on-fly increasing form rows and 3 columns and each cell contains text

  • 0

I have on-fly increasing form rows and 3 columns and each cell contains text box. I want to sum first 2 columns’ values to 3rd columns for each row. how can i do that with jquery?

let me visualize more:

     c1    c2    s
r1    5     6   11
r2    7     3   10
.     .     .    .
s   sc1   sc2  sc3

sc1,sc2,sc3 are sum of the related columns as you see.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:20:33+00:00Added an answer on May 15, 2026 at 8:20 pm

    You should build your table like this:

    <table class="summonizer">
      <thead>
        <tr>
          <th></th>
          <th>c1</th>
          <th>c2</th>
          <th>s</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th>r1</th>
          <td><input type="text" value="5"/></td>
          <td><input type="text" value="6"/></td>
          <td></td>
        </tr>
        <tr>
          <th>r2</th>
          <td><input type="text" value="7"/></td>
          <td><input type="text" value="3"/></td>
          <td></td>
        </tr>
      </tbody>
      <tfoot>
        <tr>
          <th>s</th>
          <td></td>
          <td></td>
          <td></td>
        </tr>
      </tfoot>
    </table>
    

    And your javascript should look like this:

    function summonize_table($table) {
      var col_sums = [];
      var row_sums = [];
      var all_sum = 0;
      $table.find('tbody tr').each(function(row){
        row_sums[row] = 0;
        $(this).find('td input[type=text]').each(function(column){
          value = parseInt(this.value);
          row_sums[row] += value;
          if (!col_sums[column]) col_sums[column] = 0;
          col_sums[column] += value;
          all_sum += value;
        });
      });
      $.each(row_sums,function(index,value){
        $table.find('tbody tr:eq('+index+') td:last').html(value);
      });
      $.each(col_sums,function(index,value){
        $table.find('tfoot tr td:eq('+index+')').html(value);
      });
      $table.find('tfoot tr td:last').html(all_sum);
    }
    $(function(){
      $('table.summonizer input[type=text]').live('change',function(){
        summonize_table($(this).closest('table'));
      });
      $('table.summonizer input[type=text]:first').trigger('change');
    });
    

    You can see a working example here: http://jsfiddle.net/my9DF/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a configuration object that contains values to be populated to the UI.
I have a login.jsp page which contains a login form. Once logged in the
I have an UIDatePicker and want to change it's mode on the fly. Basically
I have a dynamic (allows addition of rows on the fly) an ASP gridview
I have a data grid, where I create columns on the fly in the
I want to change a Marker's map on-the-fly. Specifically, I have three collections of
I have the need to read the Thunderbird address book on the fly. It
I have read a lot that LISP can redefine syntax on the fly, presumably
I have 3 PDF documents that are generated on the fly by a legacy
I have a PHP class that creates a PNG image on the fly and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.