Sandeep Rajput
Tera Patron

@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:

  1. u_checkbox_1
  2. u_checkbox_2
  3. 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
}

 

 

View solution in original post