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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:36:50+00:00 2026-05-26T04:36:50+00:00

Why would this not show #total as a decimal? The value of the inputs

  • 0

Why would this not show #total as a decimal?
The value of the inputs in class=”total” are a function result that stores the value in 2 decimal format. The function to display the row totals works fine but when I use the below code to total the rows when the qty field changes, the mat is correct and the change takes place correctly, but it in an int style not a currency format (2 decimal places). I have tried toPrecision as well with no change.

$('[name^=qty]').change(function(){
    var sum = 0;
    $('input.total').each(function() {
        sum += $(this).val();
    });

    $('#total').val(sum).toFixed(2);
    });

Here is the code that totals each row

function Tot(x,price,y) {
var total = CurrencyFormatted(x*price);
var v = document.getElementById(y);
v.setAttribute('value',total);}

All of these functions run just fine, totaling correctly and updating as expected, with exception to the decimal places in the grand total field.

Below is the html that I am using for each row and then the total

<td>$<input id="t1" disabled="disabled" size="8" value="0.00" class="total" />
...
<input disabled="disabled" id="total" name="total" size="8" value="0.00" />

There is nothing in the css that would change the format of the number either in the class or the table structure. I am at a complete loss, but hopefully someone will see something I don’t. Thank you in advance.

  • 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-26T04:36:50+00:00Added an answer on May 26, 2026 at 4:36 am
    $('input.total').each(function() {
        sum += parseFloat( $(this).val() );
    });
    
    $('#total').val( sum.toFixed(2) );
    

    EDIT, since i was busy i didn’t explain my answer, Greg Pettit did, so here’s the explanation

    You were trying to chain toFixed() to something that’s not a number. Also, you weren’t converting your retrieved values to floats. JS may have handled the latter, but better to run it through parseFloat as per sample

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

Sidebar

Related Questions

This would be my issue I have a drop down that's not displaying fully.
Under what circumstances would this or would this not be safe? I have a
Is there any reason something like this would not work? This is the logic
Would this be a proper way to dispose of a BackGroundWorker? I'm not sure
I'm not sure how simple this would be, but I'm using a script which
Hope this is not a dupe. I would like to be able to do
I'm not sure how I would do this in Javascript. I want to create
I thought this would be simple, but its not working .. in both the
I figured this would be simple, but being new to SSRS I'm not sure.
I assumed joinable would indicate this, however, it does not seem to be the

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.