To read the article online, visit http://www.4GuysFromRolla.com/webtech/code/FormatCurrency.shtml

 ```FormatCurrency(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, GroupDigits) (NOTE!! This function MUST have FormatNumber also provided.) ======================================================================== function FormatCurrency(num,decimalNum,bolLeadingZero,bolParens,bolCommas) /********************************************************************** IN: NUM - the number to format decimalNum - the number of decimal places to format the number to bolLeadingZero - true / false - display a leading zero for numbers between -1 and 1 bolParens - true / false - use parenthesis around negative numbers bolCommas - put commas as number separators. RETVAL: The formatted number! **********************************************************************/ { var tmpStr = new String(FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)); if (tmpStr.indexOf("(") != -1 || tmpStr.indexOf("-") != -1) { // We know we have a negative number, so place '\$' inside of '(' / after '-' if (tmpStr.charAt(0) == "(") tmpStr = "(\$" + tmpStr.substring(1,tmpStr.length); else if (tmpStr.charAt(0) == "-") tmpStr = "-\$" + tmpStr.substring(1,tmpStr.length); return tmpStr; } else return "\$" + tmpStr; // Return formatted string! } ```

 Article Information Article Title: 4GuysFromRolla.com Article Author: Scott Mitchell Article URL: http://www.4GuysFromRolla.com/webtech/code/FormatCurrency.shtml

Copyright 2018 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers