Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double.parseDouble is not working on my webpage

Tags:

javascript

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);
}
like image 480
tnlewis Avatar asked Dec 12 '22 16:12

tnlewis


1 Answers

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.

like image 196
metadept Avatar answered Jan 01 '23 17:01

metadept