Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
171
rated 0 times [  177] [ 6]  / answers: 1 / hits: 49624  / 11 Years ago, tue, october 15, 2013, 12:00:00

I need quick solution to convert currency names to currency symbols.


Like I have GBP which I want to convert into Pound symbol through small javascript/jquery code. Data is totally dynamic.


var currency_symbols = {
'USD': '$', // US Dollar
'EUR': '€', // Euro
'CRC': '₡', // Costa Rican Colón
'GBP': '£', // British Pound Sterling
'ILS': '₪', // Israeli New Sheqel
'INR': '₹', // Indian Rupee
'JPY': '¥', // Japanese Yen
'KRW': '₩', // South Korean Won
'NGN': '₦', // Nigerian Naira
'PHP': '₱', // Philippine Peso
'PLN': 'zł', // Polish Zloty
'PYG': '₲', // Paraguayan Guarani
'THB': '฿', // Thai Baht
'UAH': '₴', // Ukrainian Hryvnia
'VND': '₫', // Vietnamese Dong
};

I can't use any plugin like currenyformat.


Looking for quick help.


More From » javascript

 Answers
63

Do this:



var currency_symbols = {
'USD': '$', // US Dollar
'EUR': '€', // Euro
'CRC': '₡', // Costa Rican Colón
'GBP': '£', // British Pound Sterling
'ILS': '₪', // Israeli New Sheqel
'INR': '₹', // Indian Rupee
'JPY': '¥', // Japanese Yen
'KRW': '₩', // South Korean Won
'NGN': '₦', // Nigerian Naira
'PHP': '₱', // Philippine Peso
'PLN': 'zł', // Polish Zloty
'PYG': '₲', // Paraguayan Guarani
'THB': '฿', // Thai Baht
'UAH': '₴', // Ukrainian Hryvnia
'VND': '₫', // Vietnamese Dong
};

var currency_name = 'INR';

if(currency_symbols[currency_name]!==undefined) {
alert(currency_symbols[currency_name]);
}


NOTE: Not every currency has symbol. Only listed above currencies have real symbol.


[#74987] Sunday, October 13, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ravenl

Total Points: 338
Total Questions: 107
Total Answers: 112

Location: Belize
Member since Mon, Jun 20, 2022
2 Years ago
ravenl questions
Thu, Feb 18, 21, 00:00, 3 Years ago
Tue, Jan 12, 21, 00:00, 3 Years ago
Tue, Mar 17, 20, 00:00, 4 Years ago
;