- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 12:49 PM
Hi,
I have a requirement that needs to calculate the total cost. Total cost = Number of attendees* estimated cost on each attendee.
Please someone provide me the client script for this.
"Number of attendees" is string field, "estimated cost" is currency field and "total cos"t is currency field.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2023 08:03 PM
Hi Anand,
I tried this code but no luck.
I came up with the script that working fine. Created 2 onchange clients scripts for number of attendees, Estimated cost.
Below is the script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 01:12 PM
Hi @Yamja,
You can use below script and change field backend names according to your request
var numberOfAttendees = g_form.getValue('number_of_attendees');
var estimatedCostPerAttendee = g_form.getValue('estimated_cost');
if (numberOfAttendees && estimatedCostPerAttendee) {
var totalCost = parseFloat(numberOfAttendees) * parseFloat(estimatedCostPerAttendee);
g_form.setValue('total_cost', totalCost.toFixed(2));
}
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 11:34 AM
Hi Anand,
I tried this script in client script as onchange with field name as "total estimated cost". But I was unable to get the value of total cost depends those two fields.
Below is the screeshot of script.
Below is the screenshot example values:
Please let me know if I need to add anything.
Thank you,
Theja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 12:57 PM
Hi @Yamja,
Try below script
var numberOfAttendees = g_form.getValue('number_of_attendees');
var estimatedCostPerAttendee = g_form.getValue('estimated_cost');
if (numberOfAttendees && estimatedCostPerAttendee) {
var attendees = parseInt(numberOfAttendees, 10);
if (!isNaN(attendees)) {
var totalCost = attendees * parseFloat(estimatedCostPerAttendee);
g_form.setValue('total_cost', totalCost.toFixed(2));
}
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2023 08:03 PM
Hi Anand,
I tried this code but no luck.
I came up with the script that working fine. Created 2 onchange clients scripts for number of attendees, Estimated cost.
Below is the script: