|
|
Home > Toys > Here
Contained within this page is a JavaScript utility to convert a given numeric
value into a "dollar amount". In short, this converts
-1721.38
to
-$1,721.38
This function is based on the math routines available through your browser.
Hence it is limited to dealing with values in the +- (2**32)-1
(typically) on most of the "newer" browsers.
Furthermore, int2dollars() has to additional arguments for
prefixing and suffixing negative values (such as a <font...> tag to turn
the value red). Within this script there is a function "doit()" that
exemplifies the calling conventions. For the purposes of example, if you enter
a negative value into the "number" field, the "doit()" invocation of
int2dollars() will prepend and append an "x" to the value that will
be written into the "dollars" field.
|