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 7427885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:39:16+00:00 2026-05-29T08:39:16+00:00

I have the following table which allows a person to enter data. What I’m

  • 0

I have the following table which allows a person to enter data. What I’m trying to do is build a simple function that will work out the totals for each column.

<table>
    <thead>
        <tr>
            <th>Column1</th>
            <th>Column2</th>
            <th>Column3</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><input type="text" value="100" /></td>
            <td><input type="text" value="100" /></td>
            <td><input type="text" value="100" /></td>
        </tr>
        <tr>
            <td><input type="text" value="100" /></td>
            <td><input type="text" value="100" /></td>
            <td><input type="text" value="100" /></td>
        </tr>
        <tr>
            <td><input type="text" value="100" /></td>
            <td><input type="text" value="100" /></td>
            <td><input type="text" value="100" /></td>
        </tr>
        <tr>
            <td><input type="text" class="output" value="0" /></td>
            <td><input type="text" class="output" value="0" /></td>
            <td><input type="text" class="output" value="0" /></td>
        </tr>
    </tbody>
</table>

The jQuery I have put in place so far is:

var total = 0;
// for each table row first cell
$('table tbody tr td:nth-child(1)').each(function () {
    // add together the input values of each row
    total += parseInt($(this).find('input').val());
    // find the output for that column (note i think this is where the problem is)
    $(this).parents('tr').find('.output').val(total);
});

Doesn’t work though. Can anyone help? Thanks very much.

  • 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-29T08:39:17+00:00Added an answer on May 29, 2026 at 8:39 am
    <table>
        <thead>
            <tr>
                <th>Column1</th>
                <th>Column2</th>
                <th>Column3</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><input data-field="col1" type="text" value="100" /></td>
                <td><input data-field="col2" type="text" value="100" /></td>
                <td><input data-field="col3" type="text" value="100" /></td>
            </tr>
            <tr>
                <td><input data-field="col1" type="text" value="100" /></td>
                <td><input data-field="col2" type="text" value="100" /></td>
                <td><input data-field="col3" type="text" value="100" /></td>
            </tr>
            <tr>
                <td><input data-field="col1" type="text" value="100" /></td>
                <td><input data-field="col1" type="text" value="100" /></td>
                <td><input data-field="col1" type="text" value="100" /></td>
            </tr>
            <tr>
                <td><input data-field="col1" type="text" class="output" value="0" /></td>
                <td><input data-field="col2" type="text" class="output" value="0" /></td>
                <td><input data-field="col3" type="text" class="output" value="0" /></td>
            </tr>
        </tbody>
    </table>
    

    The jQuery:

    var total = 0;
    $('table input[data-field="col1"]:not(.output)').each(function () {
        // add together the input values of each row
        total += parseInt($(this).val());
        $(input[data-field="col1"].output).val(total);
    });
    

    repeat this for each column, and better yet, create a function that takes in the data-field and call it for each group.

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

Sidebar

Related Questions

I have a sql table which have the following data, Id City Country ---
I have the following statement that I need to run on a table which
I have the following need I have a logging table which logs som leads
I have the following table structure, which is imported into an Entity Framework project:
I have the following hsqldb table, in which I map UUIDs to auto incremented
I have an sql table which has the following rows. (4081, 3, '', 'contrapreneurship.jpg',
i have a table Students which contains the following colums: Id,FirstName,LastName,Adress . The colum
I have the following code which creates a new table. var html = '<table>';
I have the following listbox below which binds to a database table of image
I have the following html structure (which is generated and I can't change): <table

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.