I have been looking for this all day - Change currencies throughout the page when choosing between countries or currencies from dropdown menu.
What I basically need is a
I write a javascript version. no Ajax, currency change rates was borrowed from google.
HTML Code
15USD
15EUR
15BGP
15AUD
Javascript Code
var
selector = document.getElementById("currencySelector");
var
currencyElements = document.getElementsByClassName("currency");
var
usdChangeRate = {
AUD: 1.0490, // 1AUD = 1.0490 USD
EUR: 1.4407, // 1EUR = 1.4407 USD
GBP: 1.6424,
USD: 1.0
};
selector.onchange = function () {
var
toCurrency = selector.value.toUpperCase();
for (var i=0,l=currencyElements.length; i" + toCurrency.toUpperCase() + "";
el.setAttribute("data-currencyName",toCurrency);
}
}
};
Run the code
You can run the code above at http://jsbin.com/ewuyoq/5 or build your own version http://jsbin.com/ewuyoq/5/edit