如何使用正确的 javascript 允许十进制输入?

问题描述

自从我编码以来已经有一段时间了。我已经让代码工作了。输出显示时数学是正确的,但输入只允许整数。如果我尝试输入小数,结果将不会显示任何内容。我认为解析 int 行是错误的,但我不确定用什么替换它。谢谢!等式是(比特币市值/按目标币市值)*当前币价格=每枚币的最高价格

 var numOne,numTwo,numThree,res,temp;
    function crypto()
    {
      numOne = parseInt(document.getElementById("one").value);
      numTwo = parseInt(document.getElementById("two").value);
      numThree = parseInt(document.getElementById("three").value);
      if(numOne && numTwo && numThree)
      {
        temp = document.getElementById("res");
        temp.style.display = "block";
        document.getElementById("calc").value = res;
        res = (numOne / numTwo) * numThree;
      }
    }
    <p id="input">Enter Bitcoin Marketcap: <input id="one">
    <br/><br/>
    Enter Target Marketcap: <input id="two"></p>
    Enter Current Price per One Target Coin: <input id="three"></p>
    <p><button onclick="crypto()">Calculate max price per one cryptocoin</button></p>
    <p id="res" style="display:none;">
    Price Per Coin Result = <input id="calc"><br/><br/>
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)