Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
JavaScript round val to 2 decimal places

I have a script to calculate checkboxes as they are selected:

$('input:checkbox').change(function () {
  var total = 0;
  $('input:checkbox:checked').each(function () {
    total += isNaN(parseInt($(this).val())) ? 0 : parseInt($(this).val());
  });
  $("#total").val(total);
});

The total is showing as 46 rather than 46.00 for example. How can I ensure the number is always showing to 2 decimal places?

I added

console.log(format(total));

Which showed the correct format...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

total = parseFloat(total).toFixed(2);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!