-4
$(document).ready(function() {
  $('select').on('change', function() {

    $('.total_result').text(

      $('select[name=attendance]').val() * 0.25 + $('select[name=tardiness]').val() * 0.10 + $('select[name=rules]').val() * 0.05 + $('select[name=case]').val() * 0.05 + $('select[name=productivity]').val() * 0.15 + $('select[name=qa]').val() * 0.15 + $('select[name=utilization]').val() * 0.05 + $('select[name=schedule]').val() * 0.05 + $('select[name=fcr]').val() * 0.10 + $('select[name=aht]').val() * 0.05)
    ;

  });

});

I have an issue with my final code. I need to round the decimal. I'm using onchange that will auto calculate. Much appreciated. TIA

jackflick
  • 53
  • 9

1 Answers1

0

.toFixed(2); method is Used to round value.

in you example it will be like

$(document).ready(function() {
  $('select').on('change', function() {

    $('.total_result').text(($('select[name=attendance]').val() * 0.25 + $('select[name=tardiness]').val() * 0.10 + $('select[name=rules]').val() * 0.05 + $('select[name=case]').val() * 0.05 + $('select[name=productivity]').val() * 0.15 + $('select[name=qa]').val() * 0.15 + $('select[name=utilization]').val() * 0.05 + $('select[name=schedule]').val() * 0.05 + $('select[name=fcr]').val() * 0.10 + $('select[name=aht]').val() * 0.05).toFixed(2));
  });
});

Reference LINK

Faraz Babakhel
  • 654
  • 5
  • 14