How can we convert a JavaScript string variable to decimal?
Is there a function such as:
parseInt(document.getElementById(amtid4).innerHTML)
Yes -- parseFloat.
parseFloat
parseFloat(document.getElementById(amtid4).innerHTML);
For formatting numbers, use toFixed:
toFixed
var num = parseFloat(document.getElementById(amtid4).innerHTML).toFixed(2);
num is now a string with the number formatted with two decimal places.
num
2.1m questions
2.1m answers
60 comments
57.0k users