Onchange client script for calculation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2023 11:33 PM
Hi all , so this is my script for calculating values in field on changing value in GST field....
How can i modify this script... Initially CGST and SGST values '320'wil l be auto calculated at that time IGST should show only '0'...when i manually change CGST and SGST to '0' only at that time IGST should show '640'...
can i get script for it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 03:55 AM
that is expected right when you give same value then it will give the sum other wise it will be 0, If you don't want 0 then replace with space in code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 04:00 AM
var gst = parseFloat(document.getElementById("gst").value);
var cgst = 0;
var sgst = 0;
var igst = 0;
if (gst !== 0) {
cgst = sgst = gst / 2;
}
if (cgst === 0 && sgst === 0) {
igst = 640;
} else {
igst = 0;
}
document.getElementById("cgst").value = cgst.toFixed(2);
document.getElementById("sgst").value = sgst.toFixed(2);
document.getElementById("igst").value = igst.toFixed(2);
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/