【问题标题】:Double.parseDouble is not working on my webpageDouble.parseDouble 在我的网页上不起作用
【发布时间】:2013-04-01 17:19:04
【问题描述】:

我正在尝试添加一些资金并且我想使用 Double.parseDouble,但是我认为页面无法识别 double.parseDouble。我没有收到错误,但它不会添加或传递值。

这是我的代码。

function CalculateBudget(){
    var table = document.getElementById('tblBudgetTotals');
    input1600 = 0;
    input1602 = 0;
    input1603 = 0;
    input1608 = 0;
    input1612 = 0;
    funding = 0;
    budgetSum = 0;

          input1600 = Double.parseDouble(document.getElementById('txt1600').value);
    input1602 = Double.parseDouble(document.getElementById('txt1602').value);
    input1603 = Double.parseDouble(document.getElementById('txt1603').value);
    input1608 = Double.parseDouble(document.getElementById('txt1608').value);
    input1612 = Double.parseDouble(document.getElementById('txt1612').value);
    funding = Double.parseDouble(document.getElementById('FundingTotals').value);

    budgetSum += Double.parseDouble(input1600) + Double.parseDouble(input1602) + Double.parseDouble(input1603) + Double.parseDouble(input1608) + Double.parseDouble(input1612) + Double.parseDouble(funding);

    document.getElementById('totbud').value = Double.parseDouble(budgetSum);
}

【问题讨论】:

标签: javascript


【解决方案1】:

我认为你应该只使用parseFloat,因为根据these threads JavaScript 中的所有数字已经是“双精度”(64 位)浮点数。

【讨论】:

  • 谢谢。我认为做到了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-07-06
  • 2023-02-05
  • 1970-01-01
  • 1970-01-01
  • 2022-01-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多