Varada Varada - 1 year ago 185
Javascript Question

convert a javascript string variable to decimal/money

how can we convert a javascript string variable to decimal ?

is there a function such as


Answer Source

Yes -- parseFloat.


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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download