convert a JavaScript string variable to decimal/money
You can also use the Number
constructor/function (no need for a radix and usable for both integers and floats):
Number('09'); /=> 9
Number('09.0987'); /=> 9.0987
Alternatively like Andy E said in the comments you can use +
for conversion
+'09'; /=> 9
+'09.0987'; /=> 9.0987
Yes -- parseFloat
.
parseFloat(document.getElementById(amtid4).innerHTML);
For formatting numbers, use toFixed
:
var num = parseFloat(document.getElementById(amtid4).innerHTML).toFixed(2);
num
is now a string with the number formatted with two decimal places.