Format the sum of two currency fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 12:57 PM
Hi,
I have two onChange client scripts, one for the var "hardware_cost" and the secong for "installation_config_cost" and they sum to a third field. I can't get the sum mfield to properly format as US currency, with dollar signs, comma's and decimals. Here are the Scripts:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var value1 = g_form.getValue('hardware_cost').replace(/\D/g,'');
var value2 = g_form.getValue('installation_config_cost').replace(/\D/g,'');
var sum = parseFloat(value1) + parseFloat(value2);
g_form.setValue('onetime_cost_total', sum);
Here is what it returns:
How can I format the sum which is the "Onetime Cost Total." Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 01:06 PM
Is the Onetime Cost Total a currency field? Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 01:22 PM
Yes I tried that, didn't work! Our lead developer told me I need to format the sum in the script, something to that effect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 01:27 PM
That's the other option. Please let me know if it works. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 02:23 PM
Sure, however I don't know how to do that!