3

I'm trying to get the decimal place to move to the right and give me at least a 2 digit whole number. I've got the places after the decimal figured out, but not before the decimal.

The input value is divided by 36 and it's supposed to result in a percentage.

There's a fiddle here...

$(function() {
    var output_element = $('#creditRemaining');

    $('#creditRemaining').keyup(function() {  
        updateTotal();
    });


    var updateTotal = function () {
      var input1 = parseInt($('#creditRemaining').val() || 0);
      $('#total').text((input1 / 36).toFixed(2) + "% Prorated");
    };

 });

Thoughts?

Millhorn
  • 2,953
  • 7
  • 39
  • 77

1 Answers1

9

Multiply it by 100 and then use .toFixed(2)

Then this line looks like this:

$('#total').text(((input1 / 36)*100).toFixed(2) + "% Prorated");
Igl3
  • 4,900
  • 5
  • 35
  • 69