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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:24:28+00:00 2026-05-24T22:24:28+00:00

I have a table produced dynamically with each row producing something like this: <tr

  • 0

I have a table produced dynamically with each row producing something like this:

 <tr name="0">
  <td style="text-align:left;">January</td>
  <td><input type="text" name="LIB1" value="0" class="oneInput row0" /></td>
  <td><input type="text" name="RPI1" value="0" class="oneInput row0" /></td>
  <td><input type="text" name="LMM1" value="0" class="oneInput row0" /></td>
  <td><b><span class="screenOneTotal">0</span></b></td>
</tr>

I need to put the total of each input in the row in the last column when a value is input. Therefore, I placed this function in the document.ready function

$(".oneInput").live('blur', function(){
 var rowID = $(this).parent().parent().attr( 'name' );
 var thisLIB = $("input[name=LIB + rowID]" ).val();
 var thisRPI = $("input[name=RPI + rowID]").val();
 var thisLMM = $("input[name=LMM + rowID]").val();
 var rowTotal = parseFloat(thisLIB) + parseFloat(thisRPI) + parseFloat(thisLMM);
 $(this).parent().parent().find( 'span.screenOneTotal').empty().html( parseFloat(rowTotal) );
});

Despite the fact that I am explicitly casting each value to a float, the value inserted into the last column is “NaN”.

  • 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-24T22:24:28+00:00Added an answer on May 24, 2026 at 10:24 pm

    I think you’re overcomplicating things (and undercomplicating them at the same time). Your over-complication is that you’re looking for three specific things and treating them individually when you could just grab everything that fits a certain pattern and treat them as a group. Your under-complication is that you’re not considering failure conditions from parseFloat and the odd (until you’re used to it) behavior of NaN.

    I think you’d be better off going up the DOM to find the containing <tr> and the iterating through all the .oneInput elements in that row, then you can use one small chunk of code to convert the string values to sensible numbers the same way:

    $(".oneInput").live('blur', function() {
        var $row     = $(this).closest('tr');
        var rowTotal = 0;
        $row.find('input.oneInput').each(function() {
            var n = parseFloat(this.value);
            if(!isNaN(n))
                rowTotal += n;
        });
        // Do whatever you need to do with rowTotal
    });
    

    The closest call will go up the DOM to find the containing <tr>, then the find will get all the <input> elements in that row that have a class of oneInput, then loop over those with each, extract each value straight from the <input> DOM element with parseFloat, and add them to a running total in rowTotal if parseFloat finds a number (and isNaN is the what you want to check if parseFloat handed you a NaN).

    Something like this: http://jsfiddle.net/ambiguous/DBQL3/

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

Sidebar

Related Questions

I have table with 50 entries (users with such details like Name Surname Location
Imagine I have table like this: id:Product:shop_id 1:Basketball:41 2:Football:41 3:Rocket:45 4:Car:86 5:Plane:86 Now, this
I have a table which is full of arbitrarily formatted phone numbers, like this
I have a table (this cannot be changed) like the following: POST_ID | PARENT_ID
I have five text files that are produced by an R program, (each of
I have a table with more than a millon rows. This table is used
I have a table with a structure like the following: LocationID AccountNumber long-guid-here 12345
I have a table of categories. Each category can either be a root level
I have some table that was produced by a framework and I have the
I have a table with 3 columns. This table contains many raws (millions). When

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.