SharePoint Forms Multiplication of Fields

I found some JS code to use to multiply 2 fields together to get a total cost. I have found that the math is not working out completely. It will multiply whole numbers but not include any of the decimal places. What am I missing?

fd.spRendered(function() {

fd.field("TotalCost").disabled = true;

fd.field('TotalCost').value = '0.00';

fd.field('StandardCost').$on('change', function() {

  var el1 = parseInt(fd.field('Quantity').value);
  var el2 = parseInt(fd.field('StandardCost').value);

  fd.field('TotalCost').value = el1 * el2);

});
});

Hello @volkjr,

Welcome to Plumsail Community!

Use the parseFloat() function instead of parseInt() to return a floating point number:

 var el1 = parseFloat(fd.field('Quantity').value);
  var el2 = parseFloat(fd.field('StandardCost').value);
1 Like

Thank you! I figured it was something small that I was missing.