Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
275 views
in Technique[技术] by (71.8m points)

javascript - Roundoff number upto two decimal places

i am working with php ,i need to how to round off number upto two decimcal place.i want that after multiplication of two number ,when this result is used further it will take upto two decimal place ,i am working dynmically in javascripting here is the code

<script>
   function getText3(){
      var in1=document.getElementById('in1').value;
      var in2=document.getElementById('in2').value;
        var in4=document.getElementById('in4').value;
      var in3=(in1*in2*in4*30)/1000;
      document.getElementById('in3').value=in3;
   }
    function getText39(){
      var in1=document.getElementById('in1').value;
      var in2=document.getElementById('in2').value;
        var in4=document.getElementById('in4').value;
      var in39=((in1*in2*in4*30)/1000)*7.50;
      document.getElementById('in39').value=in39;
   }
     function getText89(){
      var in1=document.getElementById('in1').value;
      var in4=document.getElementById('in4').value;
        var comboB=document.getElementById('comboB').value;
      var in89=in1*in4;
      document.getElementById('in89').value=in89;
   }

i want the result in var in39,var in89,var in3 is upto two decimal place plz help me i realy need this

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Take a look at toFixed(digits).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...