Client script that adds all yes value and populates score on change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 07:02 AM - edited 01-11-2024 07:12 AM
I have 6 yes/no choice fields that i need to add all the yes values when they are changed to yes to the score field, these values are also dot walked , but client script will not execute here is the code and form view.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var questionWeight = {
'table1.question1': 2,
'table1.question2': 2,
'table1.question3': 3,
'table1.question4': 3
};
var totalScore = 0;
for (var fieldName in questionWeight) {
var choiceValue = g_form.getValue(fieldName);
if (choiceValue === 'yes') {
totalScore += parseFloat(questionWeight[fieldName]);
}
}
g_form.setValue('survey_score', totalScore);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 07:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 07:22 AM
i have it set to none because i have 6 fields that need to be onchange.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 07:26 AM
Can you paste a screenshot of the client script form.
because you still have if newValue == '' return added to the script.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 07:28 AM