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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:00:18+00:00 2026-06-13T00:00:18+00:00

I have a bit of javascript that’s working well for me, I’d just like

  • 0

I have a bit of javascript that’s working well for me, I’d just like it to keep 2 decimal places instead of hiding the extra decimal place if its 0.

Right now it says: “0.2” and I’d like it to say: “0.20”

Here’s the Javascript. Can anyone please show me how to achieve this?

 $(function() {

var valueMultiplier = <?php echo $savingsVar; ?>;

function updateAmounts() {

    // valueMultiplier = savings
    // value1 = how often do you change your printer cartridges?
    // value2 = how frequently you change them

    var value1 = $('#slider').slider('value');

    var value2 = $('#slidertwo').slider('value');

    var value3 = ((valueMultiplier * value1) * value2);
    var value3 = (Math.ceil(value3 * 10) / 10);

    // add month to it
    if(value1==1){
        value1 = value1 + ' month';
    }else{
        value1 = value1 + ' months';
    }

    value2 = value2 + ' months';

    $('#amount').val(value1);

    $('#amounttwo').val(value2);

    $('#amountthree').val(value1 + value2);

    $('#amountfour').val(value3);

    $('#amountfive').val(value3);

}

$('#slider').slider({value: 1, min: 1, max: 12, step: 1, stop: function(event, ui) {
    updateAmounts();
}});
$('#slidertwo').slider({value: 1, min: 3, max: 36, step: 3, stop: function(event, ui) {
    updateAmounts();
}});

$('#price').val("$" + valueMultiplier);

updateAmounts();
});
  • 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-13T00:00:19+00:00Added an answer on June 13, 2026 at 12:00 am

    You can use the toFixed function. It returns a string, but that should be okay in your case:

    js> x = 0.2
    0.2
    js> x.toFixed(2)
    0.20
    js> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i saw that sometimes javascript timers have a bit of lag. I would like
I have a bit of JavaScript that builds some HTML for me and inserts
I have a bit of Javascript code that creates a save friendly version of
I have a little bit of Javascript that almost works correctly. Here's the code:
With some help from SO, I have a bit of javascript/jquery that cycles through
I'm a bit of a javascript noob, but I have a general question that
I'm pulling my hair out over this. I have this bit of javascript that
I have a bit of JavaScript code that is specified in a configuration file
Lets say I have a bit of javascript code that is passed a string
I have a bit of javascript that I am using to calculate the y-scale

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.