Calculate total cost and set in variable using catalog client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 01:06 AM
Hi Team,
I have 4 different variables to enter the cost.
Onchange each variable calculate the total field and update in the total cost.
I have written below code but throwing NAN error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 03:36 AM
Hi @Rajavardhini ,
I have checked this. Yes, this issue happens when you changing the field values on which you have written on-change client script and other field values are empty.
To avoid this, I had retrieved values as Zero(0), if the field values are empty else take the value present in it.
var estimated_air = (g_form.getValue("estimated_cost_air") != '') ? g_form.getValue('estimated_cost_air') : 0;
Use the above ternary operation for all the values.
If this information helps you, Kindly mark this post as Helpful and Accept the solution.
Regards,
Najmuddin.