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?
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?
Share Improve this question asked Oct 29, 2013 at 15:22 MillhornMillhorn 3,1767 gold badges45 silver badges92 bronze badges1 Answer
Reset to default 9Multiply it by 100 and then use .toFixed(2)
Then this line looks like this:
$('#total').text(((input1 / 36)*100).toFixed(2) + "% Prorated");