- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2023 03:04 AM
Hi Team
i have calculated the sum of subjects and i used to push out the total marks in the filed of total marks but in that filed instead of total marks it shows NAN error
my script is as below
if(newValue)
{
var t=parseInt(g_form.getValue('u_telugu'));
var h=parseInt(g_form.getValue('u_hindi'));
var e=parseInt(g_form.getValue('u_english'));
var m=parseInt(g_form.getValue('u_maths'));
var s=parseInt(g_form.getValue('u_social'));
var p=parseInt(g_form.getValue('u_physics'));
var sc=parseInt(g_form.getValue('u_science'));
var k=parseInt(t+h+e+m+s+p+sc);
g_form.setValue('u_total_marks',k);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2023 07:14 AM
Hi @shaikkhasim ,
Looking at the screenshot provided. I think you have set the onChange field value = Hindi.
So you're getting a NaN error on Total Mark.
Make sure you set the Onchange field to Social.
I hope it will resolve your issue.
Regards,
Hemant
**Please mark my answer correct or helpful based on the impact**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2023 05:22 AM
try below with every variable.
var t=isNaN(parseInt(g_form.getValue('u_telugu')))?0:parseInt(g_form.getValue('u_telugu'))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2023 06:03 AM
Hi Shaikkhasim,
Assuming the values on your form are not of type Integer already.
From the code it is visible that you are trying to parseInt a value which is already a number. As parseInt is already done for those fields.
Syntax for parseInt. parseInt(string)
Can you try once to not parseInt the var k value.
var k=t+h+e+m+s+p+sc;
Hope this will resolve the issue.
Please mark the answer as helpful and correct.
Best Regards,
Rajat Choudhary
Please mark the answer as helpful and correct.
Best Regards,
Rajat Choudhary

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2023 06:55 AM
Hello Shaik,
It is showing you NaN because rest of the blanks are blank and you are converting blank string value as string.
Put some validation in the script like below -
var k =0:
If(g_form.getValue('u_hindi') != ''){
k += parseInt(g_form.getValue('u_hindi');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2023 07:14 AM
Hi @shaikkhasim ,
Looking at the screenshot provided. I think you have set the onChange field value = Hindi.
So you're getting a NaN error on Total Mark.
Make sure you set the Onchange field to Social.
I hope it will resolve your issue.
Regards,
Hemant
**Please mark my answer correct or helpful based on the impact**