- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2017 01:16 PM
Hi all,
Appreciate any help with this case:
I'm trying to get the labels from check boxes selected by user and display them on a multiple text box separated with a coma
I was trying to accomplish this with a run script with no results, I found this in another post(how to print the labels of True/False variables that are true on email templates? )
Not sure if I need an OnChange function or in the run script.
This is the original script from the other post
- template.print('<p>Environment Tiers:<br />');
- var fStr2 ='u_environment1,u_environment2'
- var fArr2 = fStr.split(',');
- for (x = 0; x < fArr2.length; x++) {
- if(current[fArr2[x]] != '') {
- var label = current[fArr2[x]].getLabel() + '<br />';
- template.print(label);
- }
- }
- template.print('</p>');
Best Regards
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2017 10:55 AM
Based upon your example, it appears that you have a variable called Selected Options that should summarize the option checkboxes that are checked.
Probably the easiest way to accomplish what you are asking for is to use an onSubmit Catalog Client Script. This will check to see what checkboxes you have checked and list them in the Selected Options variable. For sample purposes, I will use the following Variable Questions and Names:
Option 1 [var_opt_1]
Option 2 [var_opt_2]
Option 3 [var_opt_3]
Selected Options [var_opt_selected]
Here is the Catalog Client Script Details:
Name: Set Selected Options onSubmit
Type: onSubmit
UI Type: All
Applies on a Catalog Item view: true
Script:
function onSubmit() {
var cb1 = (g_form.getValue('var_opt_1') == 'true');
var cb2 = (g_form.getValue('var_opt_2') == 'true');
var cb3 = (g_form.getValue('var_opt_3') == 'true');
var selectedTxt = '';
if (cb1) {
selectedTxt += 'Option 1\n';
}
if (cb2) {
selectedTxt += 'Option 2\n';
}
if (cb3) {
selectedTxt += 'Option 3\n';
}
g_form.setValue('var_opt_selected', selectedTxt);
}
Be sure to change the values of the variables to match whatever you have in your form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2017 11:50 AM
Please mark the answer as correct so that others will see how to solution for your requirement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2017 09:10 PM
It looks like you're using mismatched variable names on lines 2 and 3. var fStr2, then fStr.split(',').
Otherwise this approach works when I test it.
var fStr2 ='u_environment1,u_environment2';
var fArr2 = fStr2.split(',');
var list = [];
for (var x = 0; x < fArr2.length; x++) {
if (current[fArr2[x]] == true)
list.push(current[fArr2[x]].getLabel());
}
template.print('<p>Environment Tiers:<br />' + list.join('<br />') + '</p>');