Changing currency in form based on user selection

By: Henry King | Asked: 08/01/2023
ForumsCategory: How-toChanging currency in form based on user selection
Henry King asked 1 year ago
Hi I've a form that has a currency field that allows user to select the currency that the figures that are entered since not all currency symbols are $ example, euro, british pound or Yen. I would like to display the currency symbol that the user has selected in all number fields that are formatted as currency. May I know how this could be acheived? Thanks. Henry
1 Answers
Best Answer
Victor Font answered 1 year ago
To do this in real time while the user is entering data requires custom jQuery. This is one way of doing it: https://formidable-masterminds.com/formatting-fields-as-currency/. You'll have to figure out how to use the library to get the different symbols. Another way is to use the built-in JavaScript Intl.NumberFormat object. See this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
Henry King replied 1 year ago

Hi thanks for your help. It seems using built-in Javascript Intl.NumberFormat is a possible solution. However, can you show how update the currency of a number field based when the user changes the currency field selection. E.g. user changed the "Currency" field from "USD" to "EURO" and the price field will be changed to 1.000 Euro instead of $1,000.
Hope it is not too much of an ask. Thanks.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right