1.remove the " EUR" --> ex: price1=price1.replace(' EUR','');
2. replace the comma with a period --> ex: price1=price1.replace(',','.');
3. evaluate both as floats (toFixed(2) if needed) --> price1=parseFloat(price1).toFixed(2);
4. add together --> price3=price1+price2;
5. replace the period with a comma --> ex: price3=price3.replace('.',',');
6. add the " EUR" --> price3=price3+' EUR';
You can condense it down a bit, but that is the basic way to do it.
Thanks, thats a big help As sometimes the currency can be different is there any way of instead of replacing the " EUR" bit, to cut the last 4 characters off instead and then adding the cut off bit back in at the end?
Thanks for this. However I tried it and when I attempt to document.write the result outputted is 19.999,99 EUR. Please could you help me find if I have something wrong in the code? Your help is a lifesaver!
Bookmarks