Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Location
    UK
    Posts
    207
    Thanks
    6
    Thanked 2 Times in 2 Posts

    currency conversions...

    Hi

    I have this code which works fantastically.

    Code:
    <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.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,252
    Thanks
    203
    Thanked 2,557 Times in 2,535 Posts
    "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."

    Code:
    <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
    Last edited by Philip M; 10-20-2008 at 01:19 PM. Reason: More info

  • #3
    Regular Coder
    Join Date
    Dec 2005
    Location
    UK
    Posts
    207
    Thanks
    6
    Thanked 2 Times in 2 Posts
    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

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,252
    Thanks
    203
    Thanked 2,557 Times in 2,535 Posts
    Google for currency converter rss feeds

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •