1
0
-1

Hello, 

I have a data driven checkbox group being given data by the Load script:

data.$checkBoxData = Calc.pipedSelection("Apple|Orange|Banana|Kiwi|Grape");

Which displays check boxes with the corresponding fruits. In a following page, I would like to display a list of the fruits which were selected. 

How is this possible? 

Thanks. 

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi,

      You could use code like this:

      var items = Form.getItemFromPath('data.datadrivenCheckboxGroup').getData();
      var selected = [];
      for (var i in items) {
        if (items[i]) {
          selected.push(i);
        }
      }

      The object returned by getData() will have properties matching the selected items, but if you select and then de-select an item in the checkbox group, the object returned by getData() will still have that property name, but its value will be set to false.  That is why the loop above checks each object property value for being truthy.  The returned object will not have a property for each checkbox item, unless it has been checked at some stage.

      If your place your code in a click rule for the checkbox group, you can just use this shorter form:

      var items = item.getData();

        CommentAdd your comment...