You are viewing limited content. For full access, please sign in.

Question

Question

Trimming total to 2 decimal places

asked on July 28, 2016 Show version history

I am looking to trim a calculated total to 2 decimal places.  I have been trying to use .toFixed(2) but it keeps preventing the code to work correctly:

 

 

$(document).ready(function () { 
  $('.Rate input').blur(function () {
    $('.GrandTotal input').val($('.Totals input').val() * $('.Rate input').val());
  });
});

 

0 0

Answer

SELECTED ANSWER
replied on July 28, 2016

What happens when you use

$(document).ready(function () { 
  $('.Rate input').blur(function () {
    $('.GrandTotal input').val(($('.Totals input').val() * $('.Rate input').val()).toFixed(2));
  });
});
1 0
replied on July 28, 2016

Thanks Alex,

 

It looks like I had it in the wrong place with a missing parenthesis.

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.