1

i want to get the output "total_amounts" like,ex(255.545645 = 255.54) and (150 =150.00). This is my code

$('.topag').on('input', function(){
var parent = $(this).closest('.calt');
var totalAmt = parseFloat(parent.find('.totalpr').val());
var quantity = parseFloat($(this).val());

parent.find('.total_amount').text(totalAmt*quantity);
$('#total_amounts').val(totalAmt*quantity);
$('#total_amounts').val(total);
calcul_total_quatities();

How can i fix this issue.

u_mulder
  • 51,564
  • 5
  • 39
  • 54
Twinxz
  • 293
  • 5
  • 15

1 Answers1

3

var total = 23.64654465;
var total_dec = total.toFixed(2);
 document.getElementById("load").innerHTML = total_dec;
<p id="load"></p>

You can use the toFixed() method. The details for this can be found at the following link. See code below for coding needed for your scenario

var totalqty = totalAmt*quantity;
var total = totalqty.toFixed(2);
document.getElementById("total_amounts").innerHTML = total;
Sphinx
  • 914
  • 8
  • 18