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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:13:35+00:00 2026-06-12T14:13:35+00:00

Possible Duplicate: How is floating point stored? When does it matter? Here is an

  • 0

Possible Duplicate:
How is floating point stored? When does it matter?

Here is an example with 3 options and 2 different problems. http://jsfiddle.net/pEpFA/7/

  1. option 1 – ground / displays properly.
  2. option 2 – express / omits the ‘0’ from the value
  3. option 3 – overnight / add’s 000000000000000 to the total.

How do i get this to work properly? I want the outcome to be displayed like option 1. Is this a javaScript bug?

HTML

<label><input type="radio" name="print" class="option" data-number="25.72" /> UPS Ground </label>
<br>
<label><input type="radio" name="print" class="option" data-number="80.90" /> UPS Express </label>
<br>
<label><input type="radio" name="print" class="option" data-number="112.93" /> UPS Overnight </label>

<br><br>
Shipping
$<span id="ship_total"></span>

<br>
Final Total
$<span id="new_total"></span>

jQuery

$(document).ready(function() {
      $('label').click(function() {
         var total = 0;

          $('.option:checked').each(function() {
              total += Number($(this).data('number'));   
          });
              $('#ship_total').text(total);

                  //php echos the subtotal
                 var sub_total = 550.25;

                 var ship_total = ($("#ship_total").text());

                var final_total = parseFloat(sub_total) + parseFloat(ship_total);

        $('#new_total').text(final_total);
    });

    });

See jsfiddle DEMO: http://jsfiddle.net/pEpFA/7/

  • 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-12T14:13:36+00:00Added an answer on June 12, 2026 at 2:13 pm

    http://jsfiddle.net/pEpFA/9/ (Updated all values)

    Pay attention to those lines below in the fiddle above:

     total = total.toFixed(2);
     ...
     final_total = final_total.toFixed(2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How is floating point stored? When does it matter? Using the built-in
Possible Duplicate: Dealing with accuracy problems in floating-point numbers I was quite surprised why
Possible Duplicate: Strange floating-point behaviour in a Java program Why does JSP/JSTL division by
Possible Duplicate: What is a simple example of floating point/rounding error? When I execute
Possible Duplicate: Floating Point Limitations Using Python 2.7 here. Can someone explain why this
Possible Duplicate: Dealing with accuracy problems in floating-point numbers Code: float flt = 78983636;
Possible Duplicates: Is JavaScript’s Math broken? How is floating point stored? When does it
Possible Duplicate: Floating point issue in C #include<stdio.h> main() { int a,b; float f;
Possible Duplicate: C compiler bug (floating point arithmetic)? I've got two doubles which I
Possible Duplicate: Why does overflow hidden stop floating elements escaping their container? Why my

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.