What can I use to convert this string into a number? "$148,326.00"
I am guessing that I need to explode it and take the dollar sign off, and then use parseFloat()? Would that be the wisest way?
This is how I am getting the number:
var homestead = xmlDoc.getElementsByTagName("sc2cash");
document.getElementById('num1').innerHTML = homestead[1].textContent;
You need to remove the dollar signs and commas, (string replace), then convert to a
floatvalueTry this:
See: http://www.w3schools.com/jsref/jsref_parseFloat.asp
Or: http://www.bradino.com/javascript/string-replace/
To handle other currency symbols you could use the following instead (which will remove all non numeric values (excluding a
.and-)):