How to sum two or more currency values?

function onSubmit() {

var Price1 =parseDecimal(g_form.getValue(‘u_price’)); // Call parseDecimal function
var Price2 =parseDecimal(g_form.getValue(‘u_price_2’));// Call parseDecimal function
var Total = Price1 + Price2 ;
g_form.setValue(‘u_total’,Total);//populate total field by the sum of Price1 and Price2


function parseDecimal(d) {

// Remove currency and any potential any undesirable character

// Loop through the currency and replace the comma
while (d.indexOf(“,”) != d.lastIndexOf(“,”))

return parseFloat(d);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s