Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2024 08:34 AM - edited 08-20-2024 08:35 AM
@heathers_ You can try the following onLoad script and form an array of selected checkbox label.
Let's say you have the following checkbox fields:
- u_checkbox_1
- u_checkbox_2
- u_checkbox_3
function onSubmit() {
var selectedValues = []; // Array to store selected checkbox values
// Check each checkbox field and add its value to the array if it is checked
if (g_form.getValue('u_checkbox_1') == 'true') {
selectedValues.push(g_form.getLabelOf('u_checkbox_1')); // Push the label or value
}
if (g_form.getValue('u_checkbox_2') == 'true') {
selectedValues.push(g_form.getLabelOf('u_checkbox_2'));
}
if (g_form.getValue('u_checkbox_3') == 'true') {
selectedValues.push(g_form.getLabelOf('u_checkbox_3'));
}
// Join the array into a single comma-separated string
var selectedValuesString = selectedValues.join(', ');
// Set the value of the target field with the comma-separated list
alert(selectedValuesString);
return true; // Allow the form submission to proceed
}