- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 03:38 PM
-I need to get the count of the checkbox script but is not working correctly. i keep giving the result of 4 regardless of what i select. the script below was what i created.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
// Replace the following variable names with the actual names of your checkboxes
var checkboxVars = ['ac_photoshop','ac_illustrato','ac_indesign','ac_premiere'];
var selectedCount = 0;
for (var i = 0; i < checkboxVars.length; i++) {
if (g_form.getValue(checkboxVars[i]) === 'true') {
selectedCount++;
}
}
g_form.setValue('checkbox_count', selectedCount);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 05:54 PM
Hi,
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Replace the following variable names with the actual names of your checkboxes
var checkboxVars = ['ac_photoshop','ac_illustrato','ac_indesign','ac_premiere'];
var selectedCount = 0;
for (var i = 0; i < checkboxVars.length; i++) {
// Check if the checkbox is true (boolean), not a string 'true'
if (g_form.getValue(checkboxVars[i]) == true) {
selectedCount++;
}
}
// Update the field with the count
g_form.setValue('checkbox_count', selectedCount);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 05:54 PM
Hi,
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Replace the following variable names with the actual names of your checkboxes
var checkboxVars = ['ac_photoshop','ac_illustrato','ac_indesign','ac_premiere'];
var selectedCount = 0;
for (var i = 0; i < checkboxVars.length; i++) {
// Check if the checkbox is true (boolean), not a string 'true'
if (g_form.getValue(checkboxVars[i]) == true) {
selectedCount++;
}
}
// Update the field with the count
g_form.setValue('checkbox_count', selectedCount);
}