Currency

From Jsorm

Jump to: navigation, search

Currency is a class to simplify presenting and formatting currency information. It is entirely client-side, with no server-side dependency other than loading the initial code. Currency assumes that you have an amount as a raw number, generally a float. You create a Currency object in the standard, JavaScript method, passing the constructor an argument as to which international currency you wish to use. You can then ask the Currency object to output the amount in that currency's standard format.

The currency name is always the three-character, upper-case international standard currency symbol, as defined by ISO 4217.

The following example illustrates a basic use of Currency.

var cur = JSORM.currency('USD');
var format = cur.format(32125.67);
// will output a string: $32,125.67

Additionally, a currency can tell you what its name is and what country it is from.

var country = cur.getCountry(); // returns "United States"
var name = cur.getName(); // returns "Dollar"

Finally, you can determine the list of available currencies by using the static method JSORM.currency.getCurrencies()

var list = JSORM.currency.getCurrencies(); // returns a list of supported currencies

It is strongly recommended that you refer to the API documentation.

Personal tools