建立具有不同选择的计算器

时间:2019-11-20 21:02:14

标签: javascript html calculator

我正在为我们的公司制造计算器,但是我们遇到了问题。

我们正在处理某些宽度。我控制住了。 例如,必须通过特定公式将100的宽度四舍五入为98.4,这已经全部实现了!

现在选择一个选项后必须使用98.4。 例如,当选项

时,必须将98.4除以12.3
<option id = "222"> 20 cm, hooks overlap 2 </option>
选择

。以此类推。 这就是我们所拥有的,请帮忙。

如果您需要查看实物; http://calculator.verfuurden.com/

<button class="open-button" onclick="openForm()">Strokencalculator</button>
<div class="form-popup" id="myForm">


   <div class="calc-container">
      <div id="login-row" class="row justify-content-center align-items-center">
         <div id="login-column" class="col-sm-12 col-md-12">
            <div id="login-box" class="col-md-12">

               <form id="login-form" class="form" action="" method="post">

               <strong class="logo">
                  <img src="/img/logo_enkel_lisoflex_logo.jpg" width="270" height="auto">
               </strong>

                  <div class="form-group">
                     <label for="breedte" class="text-info">Width in cm</label><br>
                     <input type="text" name="breedte" id="firstNumber" class="form-control">
                  </div>

                  <div class="form-group">
                     <label for="breedte" class="text-info">the exacte width will be;</label><br>
                     <label class="form-control" id="result"></label>
                  </div>


                  <div class="form-group">
                     <label for="strookmaat" class="text-info">Required strip size and overlap:</label><br>
                     <select class="form-control select2">
                        <option id="102">10cm, hooks overlap 0</option>
                        <option id="212">20cm, hooks overlap 1</option>
                        <option id="222">20cm, hooks overlap 2</option>
                         <hr>
                        <option id="313">30cm, hooks overlap 1</option>
                        <option id="333">30cm, hooks overlap 3</option>
                         <hr>
                        <option id="414">40cm, hooks overlap 1</option>
                        <option id="424">40cm, hooks overlap 2</option>
                        <option id="434">40cm, hooks overlap 3</option>
                        <option id="444">40cm, hooks overlap 4</option>
                     </select>
                  </div>

                  <div class="form-group">  
                  <input type="button" class="btn btn-primary" onClick="divideBy()" Value="Calculate" /><br><br>
                  <label for="aantal" class="text-info">Needed number of strips;</label>  <strong><span id="result2"></span></strong>
                  </div>

               </form>
               <button type="button" class="btn cancel" onclick="closeForm()">Close calculator</button>

            </div>
         </div>
      </div>
   </div>


</div>



<script type="text/javascript">
function divideBy() {
    var num1 = document.getElementById("firstNumber").value;
    document.getElementById("result").innerHTML = Math.round(Math.floor(num1 / 4.1) * 4.1 * 10) / 10;
}

</script>

0 个答案:

没有答案