...

View Full Version : currency conversions...



many_tentacles
10-20-2008, 12:09 PM
Hi

I have this code which works fantastically.


<script type="text/javascript">
exchRate = 1.3;
function getUSD(price) {
document.write('(' + price * exchRate + ' &euro;)');
}
</script>
<p>Price: &pound;1.40 <script type="text/javascript"> getUSD('1.4'); </script></p>

However, it will require someone changing the exchange rate manually as it changes. So my first question is this... Is there any way I can grab the latest exchange rate from a 3rd party??

Secondly, I need to display the converted price rounded to 2 decimal places. I'm sure I'll be able to work this one out with a little searching around, but any help would be appreciated.

Many thanks.

Philip M
10-20-2008, 12:31 PM
"So my first question is this... Is there any way I can grab the latest exchange rate from a 3rd party??"

No, not with Javascript. There are various RSS feeds available.
See: e.g. http://www.xe.com/dfs/ and Google for others.
A free currency converter is provided by:-
http://www.currencysource.com/webmasters.html

"Secondly, I need to display the converted price rounded to 2 decimal places."


<script type="text/javascript">
var exchRate = 1.3;
function getUSD(price) {
var np = (price * exchRate).toFixed(2);
document.write('(' + np + ' &euro;)');
}
</script>
<p>Price: &pound;1.40 <script type="text/javascript"> getUSD('1.4'); </script></p>


"Can you do addition?" the White Queen asked. "What's one and one and one and one and one and one and one and one and one and one?" "I don't know," said Alice. "I lost count." - Lewis Carroll

many_tentacles
10-20-2008, 01:18 PM
Thanks for that.

OK, so we've established that it's not easy to automate the exchange rate updating...

Is it possible using ASP.net??

Otherwise, what is the best service that I can pay for. Ideally with little or no banners. Is it the XE.com one you mentioned?

Thanks

Philip M
10-20-2008, 01:22 PM
Google for currency converter rss feeds

A free currency converter is provided by:-
http://www.currencysource.com/webmasters.html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum