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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:03:36+00:00 2026-06-07T14:03:36+00:00

I started off by using this solution, but I can’t seem to get it

  • 0

I started off by using this solution, but I can’t seem to get it to work

jQuery calculate sum of values in all text fields

Here is an example of my html

<table>
  <tbody>
    <tr id="tr_affiliation_15159">
      <td class="right col_aff_amount">15.00</td>
    </tr>
    <tr id="tr_affiliation_15189">
      <td class="right col_aff_amount">15.00</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td class="total"></td>
    </tr>
  </tfoot>
</table>

This is my javascript function

function removeRow(id) {
  $("#tr_affiliation_" + id).fadeOut("slow", function() {
    $("#tr_affiliation_" + id).remove();

    // recalc total
    var total = 0;

    $('.col_aff_amount').each(function() {
      // i have tried .text(), and .html() as well as .val() but it doesn't seem to make any difference
      var val = parseFloat($(this).val());
      console.log(val);
      total += val;
  });

  $("td.total").html(parseFloat(total).toFixed(2));

}

My console log just shows a long list of NaN, why can’t it extract the number?

  • 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-06-07T14:03:37+00:00Added an answer on June 7, 2026 at 2:03 pm

    you should use text() for elements other than form elements like input and textarea, also as you are doing calculation, define the variable val with an integer value before calculatiing:

    $(document).ready(function(){
       // ...
       var val = 0;
       val = parseInt($(this).text(), 10);
      // ...
    })
    

    DEMO

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

Sidebar

Related Questions

I wanted to create jquery plugin & started off creating a sample jquery plugin...But
To start off, I'm using Asp.Net MVC 4, and I've modified my solution to
I have a portfolio made in C#/ASP.NET which started off small but, as it
I just started using GIT yesterday and i was trying to do something but
I am creating a dynamic visualization using Raphael-js. I started off with using Raphael-1.5.0
I started using the lattice graphic package but I stumbled into a problem. I
I just started off with OpenMP using C++. My serial code in C++ looks
So I started off with this query: SELECT * FROM TABLE1 WHERE hash IN
I've seen the three implementations of pre-selecting a checkbox. I started off using checked=checked
None of us started off as experts (and most of us still aren't). Sure,

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.