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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:16:36+00:00 2026-06-01T06:16:36+00:00

How would I round off a value from a textfield with a parseFloat result

  • 0

How would I round off a value from a textfield with a parseFloat result in it? This application basically sums up the value of all radio buttons when clicked and displays the sum in a textbox.

The code below works perfectly if the radio button value is an integer, however if I want to have a floating point value on the radio button, the total value will have a 100.0000000679 when it should be 100. Any tips would be very much appreciated. Thanks in advance.

function calcscore(){
  var score = 0;
  $(".calc:checked").each(function(){
    score+=parseFloat($(this).val(),10);
  });
  $("input[name=openingsum]").val(score);
}
$().ready(function(){
    $(".calc").change(function(){
        calcscore();
    });
});

HTML Code:

<input class="calc" name="v2" type="radio" onclick="ver2(this);" value="1.6666666666666666666666666666667" />Yes
<input class="calc" name="v2" type="radio" onclick="ver2(this);" value="0" />No
  • 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-01T06:16:37+00:00Added an answer on June 1, 2026 at 6:16 am

    At first i think you provided us with a different example then expected. If you tell us something about getting 100.0000000679 and in your code is only a value of 1.6666666666666666666666666666667 there is something wrong 🙂

    So I hope your problem is only to round the correct way. For that you can use .toFixed()

    See the example on jsfiddle

    HTML:

    <input class="calc" name="v1" type="radio" onclick="ver2(this);" value="1.6666666666666666666666666666667" />Yes
    <input class="calc" name="v1" type="radio" onclick="ver2(this);" value="0" />No
    <br>
    <input class="calc" name="v2" type="radio" onclick="ver2(this);" value="1.6666666666666666666666666666667" />Yes
    <input class="calc" name="v2" type="radio" onclick="ver2(this);" value="0" />No
    <br>
    <input class="calc" name="v3" type="radio" onclick="ver2(this);" value="1.6666666666666666666666666666667" />Yes
    <input class="calc" name="v3" type="radio" onclick="ver2(this);" value="0" />No
    <br>
    <input type="text" name="openingsum">​
    

    JAVASCRIPT:

    function calcscore(){
      var score = 0;
      $(".calc:checked").each(function(){
        score+=parseFloat($(this).val(),10);
      });
      score = score.toFixed(2);
      $("input[name=openingsum]").val(score);
    }
    $().ready(function(){
        $(".calc").change(function(){
            calcscore();
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I round the result from two divided numbers, e.g. 3/2 As when
If I have a double (234.004223), etc., I would like to round this to
I would like my text entry to round off decimals and have the end
I'me looking for a function that would receive a time and would round it
I am using a BizTalk orchestration to kick off an SSIS package. This package
I am developing an app and want to round off values i.e if the
I have a number of methods that ultimately call my this._context.SubmitChanges method. Because all
this is hard to describe but I am currently catching a string from a
I would like to get a byte[] from a float[] as quickly as possible,
I have been searching round the internet for days on this matter but I

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.