Display Currency conversion on the fly

Forums General discussion Display Currency conversion on the fly

Tagged: 

Viewing 3 reply threads
  • Author
    Posts
    • #33212
      Brett
      Participant

      Hi Alexander,

      I’ve got a query from our purchasing team:
      As dollar amounts are typed on to the form from various currencies, can we display latest currency conversion amounts? AUD, USD, GDP, EUR.
      Because they receive various quote amounts from different countries, they would have to select the source currency, eg: 350 USD, which then displays current converted amounts.
      I had a try using this ext blog post but I kept getting errors in JS.
      I’ll put some money in your bank if you have time to knock out a solution 🙂
      Thanks.

    • #33215
      Brett
      Participant

      If it’s easier, any JS currency conversion widget I can embed in to a DFFS Form would be great. I’ve tried a few but can’t get any to work with IE10/11 and DFFS.

      • This reply was modified 5 months, 1 week ago by Brett.
    • #33224
      Alexander Bautz
      Keymaster

      I haven’t done this myself so I don’t have an account with this webpage, but if you can show me what kind of error are you getting I can take a look

      Alexander

    • #33248
      Brett
      Participant

      Hi Alexander,
      I’ve just got this currency converter widget to display on the form.
      https://currencyrate.today/converter-widget

      I extracted their JS code and pasted it in custom JS using a rule to trigger the function on run-time.

      From code in another post, I added

      <div id="currencywidget"></div>

      to the Text or HTML field and within their code, replaced document.write with

      jQuery("#currencywidget").html

      and it works, the widget displays on the form.

      It does take up a bit of space so I’ll use some CSS to push it off to the side.
      Final result attached.
      I think they’ll be happy with this for now.
      Thanks.
      *I tried pasting code here using the tags but my comment is not saving.

      • #33251
        Brett
        Participant

        Pasting my custom JS code here for anyone who needs to embed a currency converter.

        
        
        function currencyconvert(){
            
        var fm = "USD";
        var to = "AUD";
        var tz = "timezone";
        var sz = "160x289";
        var lg = "en";
        var st = "info";
        var lr = "0";
        var rd = "0";
        
        if (!sz) {
            var sz = '1x1';
        }
        if (!tz) {
            var tz = '0';
        }
        var arr = sz.split("x");
        var tz = tz;
        var lg = lg;
        var fm = fm;
        var to = to;
        var st = st;
        var lr = lr;
        var rd = rd;
        if (tz == "timezone") {
            var d = new Date();
            tz = d.getTimezoneOffset() / 60;
            tz = 0 - tz;
            tz = tz + "s";
        } else if (tz == "userset") {
            var d = new Date();
            tz = d.getTimezoneOffset() / 60;
            tz = 0 - tz;
        }
        if (!st) {
            st = "info";
        }
        if (!rd) {
            rd = 0;
        }
        if (!fm) {
            fm = 'USD';
        }
        if (!to) {
            to = 'EUR';
        }
        var w = parseInt(arr[0]);
        var h = parseInt(arr[1]);
        if (w == 1 || w < 1 && h == 1 || h < 1) {
            w = '100%';
            if (lr == 1) {
                h = 306;
            } else {
                h = 289;
            }
        }
        ht_protocol = (location.protocol == "https:" ? "https:" : "http:");
         jQuery("#currencywidget").html('<a href="http://'%20+%20ht_protocol%20+%20&#039://currencyrate.today/load-converter?&lg='%20+%20lg%20+%20'&tz='%20+%20tz%20+%20'&fm='%20+%20fm%20+%20'&to='%20+%20to%20+%20'&st='%20+%20st%20+%20'&lr='%20+%20lr%20+%20'&rd='%20+%20rd%20+%20'">http://'%20+%20ht_protocol%20+%20&#039://currencyrate.today/load-converter?&lg='%20+%20lg%20+%20'&tz='%20+%20tz%20+%20'&fm='%20+%20fm%20+%20'&to='%20+%20to%20+%20'&st='%20+%20st%20+%20'&lr='%20+%20lr%20+%20'&rd='%20+%20rd%20+%20'</a>');
        
        }
      • #33255
        Alexander Bautz
        Keymaster

        I’m glad you figured it out – and thanks for posting the solution here.

        Alexander

Viewing 3 reply threads
  • You must be logged in to reply to this topic.