I’m trying to change the value on the page while when loaded and changing the currency with a simple calculation.
If any one can help me that be great,,
here is my code:
<head>
<script type="text/javascript">
function myscript() {
var input = document.getElementById('span1').innerHTML;
output = '$19,999.9 AUD';
document.body.innerHTML = document.body.innerHTML.replace(input,output);
}
</script>
</head>
<span id="span1" class="text field">$9,999.9 USD</span>
<body OnLoad = "myscript();">
</body>
So basically I want to know how to make it take ONLY the numbers from id=”span1″ text field and do a simple calculation like + 10 and replace USD with AUD without losing the , and .
I have tried to make use of parseInt but didn’t get it to work.
Thanks you in advance 🙂
EDIT:
Please NOTE that the span1 value is dynamic and always changing
A simple way is to just grab the numbers from the string.
I would also recommend that the currency type USD and AUD not be part of the span1 but be part of span2 that is shown right after. This way the parsing doesn’t need to handle it.