Format an input number

Asked

Viewed 174 times

0

I have a system that calculates the average of the fields and then executes the javascript below, only the result comes out like this 0.222048 and the correct would be 222.048, how to do this conversion?

<script>
     function calcularMediam3etes() {
        var m1 = document.forms['formMediasETEs']['mediaQ_lsE'].value;
        var mqm3 = (m1 * 86.400)/1000;
        document.forms['formMediasETEs']['mediaQm3E'].value = mqm3;
    }
</script>

inserir a descrição da imagem aqui

Thank you!

  • 2

    You’ve tried not splitting by a thousand?

  • The problem is that the calculation has to be divided by a thousand, the formula is N * 86.400 / 1000. With this calculation we discovered the daily flow per cubic meter, there is no way to take. ;(

  • If the formula is correct, why would the result be wrong? I imagine that the division per thousand makes the resulting number have as unit the cubic meter. Without the division the unit would be liters. Pra min seems a matter of converting between units of measures. Based on the example you gave.

  • Because the result comes out like this 0.222048 and the correct would be 222.048, in excel, calculator or any other comes out normal.. only in the code that comes out of the format I need. Have any ideas to help? I already took the division / 1000, but tb not solved because of the point of the decimal places.

  • Maybe the result is then supposed to come out in dm cubico

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.