Here is a function that was found on this Stack Overflow thread and is intended to convert a numeric value into a US currency format. Please add the following to the Page Level Javascript section of your parent form.
Number.prototype.formatMoney = function(c, d, t){
var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};
In my form, I have a field which performs subform aggregation of an order form I put together with the following details.
Form Name: customer_order_parent
Subform data column name: choose_plan__items
Aggregate Element on subform: subtotal
To convert this aggregate value into a currency on my parent form, I apply the following Dynamic Value to a Read-Only element.
"$"+iformbuilder.math.sum(customer_order_parent.choose_plan__items, 'subtotal').formatMoney(2, '.', ',');
Comments
0 comments
Please sign in to leave a comment.