convert a JavaScript string variable to decimal/money

The Solution to convert a JavaScript string variable to decimal/money is


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.

~ Answered on 2011-05-23 10:16:19


Most Viewed Questions: