If you want your calculation field to deliver a monetary value for customer or user appeal, LOOK NO FURTHER.

EXAMPLE

enter: 1234567

will return: $1,234,567.00

In a normal situation, if you are calculating the values of 2 fields, the calculation field will return you a value void of commas or the monetary identifier of your choice, ($, £, €, etc...). This is because the calculation field is built to return a value that is ready to be calculated once again, void of any strings or confusion. But, for those of you who desire to add this type of eye candy to your end calculation, below is your formula:

Directions

Highlight everything between the lines, and place in your calculation field. Place the fieldkey you are referencing in the "$field_key$" area of the calculation. If you want to change the monetary indicator from Dollars ($) to something else of your choice, then find r = "$" + n.toFixed(2); in the formula below, and replace the $ with the symbol of your choice.

Formula

--------------------------------------------------------------------------------------

function formatCurrency(nStr)

{

nStr += '';

var x = nStr.split('.');

var x1 = x[0];

var x2 = x.length > 1 ? '.' + x[1] : '';

var rgx = /(\d+)(\d{3})/;

while (rgx.test(x1)) {

x1 = x1.replace(rgx, '$1' + ',' + '$2');

}

return x1 + x2;

}

n = float($field_key$);

r = "$" + n.toFixed(2);

return formatCurrency(r);

-------------------------------------------------------------------------------------

Here are a few pictures to illustrate

How You Do It

The Result

## Comments