- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 12:34 AM
Hello all
I have more then 50 checkbox in my catalog items.. Among this 50 checkbox only the selected values must be shown in the multiline text.
My below code is not working, I'm testing it with 3 checkbox in the below script.. Please help me here
function onSubmit() {
var v1 = g_form.getValue('check1');
var v2 = g_form.getValue('check2');
var v3 = g_form.getValue('check3');
var arr = [v1, v2, v3];
var arr2 = [];
for (var i in arr) {
if (arr[i] == true) {
arr2.push(arr[i]);
g_form.setValue('check_box_values', arr2);
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 12:39 AM
@David Cross can you try (arr[i] == 'true') i.e. true as string instead of Boolean once and see if that makes it work.
Best regards
Suyog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 12:43 AM
Hello @David Cross
Try this -
var i =0;
var v1 = g_form.getValue('check1');
var v2 = g_form.getValue('check2');
var v3 = g_form.getValue('check3');
var arr = [v1, v2, v3];
var arr2 = [];
for (i=0; i<arr.length; i++) {
if (arr[i] == 'true') {
arr2.push(arr[i]);
}
}
g_form.setValue('check_box_values', arr2);
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.