最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Double.parseDouble is not working on my webpage - Stack Overflow

matteradmin2PV0评论

I'm trying to add some funds and I want to use Double.parseDouble but, I don't think the page is recognizing double.parseDouble. I don't get an error but it won't add or pass the values.

Here is my code.

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);
}

I'm trying to add some funds and I want to use Double.parseDouble but, I don't think the page is recognizing double.parseDouble. I don't get an error but it won't add or pass the values.

Here is my code.

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);
}
Share Improve this question edited Apr 1, 2013 at 18:38 Leigh 28.9k10 gold badges57 silver badges109 bronze badges asked Apr 1, 2013 at 17:19 tnlewistnlewis 3231 gold badge3 silver badges16 bronze badges 2
  • Have you declared a double object that contains a parseDouble function? If not then I believe you may be looking for parseFloat as described here: developer.mozilla/en-US/docs/JavaScript/Reference/… – Chase Commented Apr 1, 2013 at 17:24
  • 1 Is there any particular reason this question has a coldfusion tag? – Dan Bracuk Commented Apr 1, 2013 at 17:52
Add a ment  | 

1 Answer 1

Reset to default 13

I think you should just be using parseFloat for this, since according to these threads all numbers in JavaScript are already "double precision" (64-bit) floats.

Post a comment

comment list (0)

  1. No comments so far