Home › Forums › General discussion › Display Currency conversion on the fly
Tagged: currency
- This topic has 5 replies, 2 voices, and was last updated 3 years, 8 months ago by Alexander Bautz.
-
AuthorPosts
-
-
April 15, 2021 at 02:58 #33212
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. -
April 15, 2021 at 07:07 #33215
-
April 15, 2021 at 16:32 #33224
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
-
April 15, 2021 at 23:49 #33248
Hi Alexander,
I’ve just got this currency converter widget to display on the form.
https://currencyrate.today/converter-widgetI 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.Attachments:
-
April 15, 2021 at 23:51 #33251
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'://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'://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>'); }
-
April 16, 2021 at 08:21 #33255
I’m glad you figured it out – and thanks for posting the solution here.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.