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

  • Home
  • SEARCH
  • 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 6700735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:51:01+00:00 2026-05-26T06:51:01+00:00

Ok i have this table where the last column is a number only column

  • 0

Ok i have this table where the last column is a number only column and is formatted with thousand separators and decimal.
Here’s a sample code:

<html>
<head>
<script src="jquery.js"></script>
<script src="includes/autoNumeric.js"></script>
<script type="text/javascript">
$(document).ready(function() {
jQuery(function($) {
    $('input.auto').autoNumeric();
});
$("#table").keyup(function(){
    var sal_total = 0;
    $(".salary[value!='']").each(function() {
        sal_total += Number($(this).val());
    });
    $('#total').val(sal_total);
});
$("#addRow").click(function() {
    var newRow = "<tr><td><input type=\"text\"></td><td><input type=\"text\"></td><td><input type=\"text\" class=\"auto salary\"></td></tr>";
$("#table tr.totalRow:last").before(newRow);
});
});
</script>
</head>            
<body>
<table id="table" border="1">
<tr>
    <td>ID</td>
    <td>Name</td>
    <td>Salary</td>
</tr>
<tr>
    <td><input type="text" ></td>
    <td><input type="text" ></td>
    <td><input type="text" class="auto salary"></td>
</tr>
<tr>
    <td><input type="text" ></td>
    <td><input type="text" ></td>
    <td><input type="text" class="auto salary"></td>
</tr>
<tr>
    <td><input type="text" ></td>
    <td><input type="text" ></td>
    <td><input type="text" class="auto salary"></td>
</tr>
<tr>
    <td colspan="2">Total</td>
    <td><input type="text" id="total" readonly="readonly" /></td>
</tr>
</table>
<div align="center">
    <input type="button" id="addRow" value="Add Row" />
    <input type="submit" name="save" value="Save" />
</div>
</body>
</html>

The salary column is automatically formatted with autoNumeric plugin to insert comma every thousand and put decimal point, i would like to add those salary values every keypress and put the sum in input#total. It works when i remove the commas but produces NaN when there is, plus whenever i add a row autoNumeric does not work on that particular row. Please help I’m just a newbie on this.

  • 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-26T06:51:02+00:00Added an answer on May 26, 2026 at 6:51 am

    To convert to actual numbers (rather than strings), you have to remove the commas.

    Change this:

    sal_total += Number($(this).val());
    

    to this:

    sal_total += Number($(this).val().replace(/\$|,/g, ""));
    

    This will remove commas and dollar signs before attempting to convert it to a number.

    If you want the commas back in when you place the total back into the page, you will have to reinsert the commas after you’ve obtained the total.

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

Sidebar

Related Questions

I have a table with columns ID(int), Number(decimal), and Date(int only timestamp). There are
I have this table: fourn_category (id , sub) I am using this code to
I have made the following search script but can only search one table column
I have a form with the fields inside table cells. On the last column
I have some irregular data in one column. my.table <-read.table(text=ticker,date,last a,12/20/2011,289295 a,12/21/2011,NA a,12/27/2011,297001 a,12/28/2011,NA
i have a table (tbl_world) which look like this id | first_name | last_name
I have this code: tableList = [[NSMutableArray alloc] initWithObjects:@First View,@Second View,nil]; I have synthesized
I have this table in an Oracle DB which has a primary key defined
I have this table CREATE TABLE [dbo].[friend_blocked_list]( [subdomain] [varchar](50) NOT NULL, [un] [nvarchar](50) NOT
I have this table CREATE TABLE `codes` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT,

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.