2
I have 3 Javascript variables:
valorUm = 2.8 //dois ponto oito
valorDois = 2.415 //dois mil quatrocentos e 15
valorLivre = 25 //vinte e cinco
What I need is:
valorUm + valorDois - valorLivre
this calculation returns me -19.785 and should return me 2392.8
I’m recovering input values:
valorUm = parseFloat(document.getElementById('ab').value.replace(",","."));
valorDois = parseFloat(document.getElementById('bc').value.replace(",","."));
valorLivre = parseFloat(document.getElementById('livre').value);
The account is right according to what you showed. The second number is 2 point 415 and there’s nothing thousand there. If you want a thousand then the number is
2415
. The conversion seems to be ok. What may be wrong is that it is coming in a format that is not what you expect. How are the values being typed?– Maniero
The values come from automatic calculations of the google maps api, I am recovering the values that comes '2.415 km', removing the text and calculating. But, these values are variable, can be 10.000 km or 2 km, IE, there is something that can do, so that regardless of the value returned to me comes an exact calculation?
– sNniffer
How’s the shape in
bc
? The exact way the number gets?– Maniero
in the input "2.415 km"
– sNniffer
Got it, removed the points from bc, before giving replace. It worked blz
– sNniffer
That’s what I said.
– Maniero
That’s right @bigown did what explained, vlw same guy.
– sNniffer