Dynamic Checkbox Options

In Frevvo you are able to create dynamic checkbox options that will appear depending on what options the user selects in another control.

Example: We have form with a checkbox control (Checkbox_A) that contains a list of files the user can request access to. Depending on what options the user selects, we want to display certain options in a checkbox (Checkbox_B) for the supervisor.

Depending on what is selected we an option to appear for each instance that says: “I give my approval for ________ files.” We also want to add an option for when we don’t want to approve the user access to any of the files. However this option should only appear when at least 2 options are selected.

The rule should look something like this:

//options is an array
var options = [];
//create variables for the dynamic options
var bud = 'I give my approval for Budget files.';
var op = 'I give my approval for Operation files.';
var emp = 'I give my approval for Employee files.';
var non = 'I do not give my approval any files.';
//trigger for this rule is a button called Trigger
if(Trigger.clicked){
  
  for (var i = 0; i < Checkbox_A.value.length; i++){
    
    //if budget is selected
    if(Checkbox_A[i].value === 'Budget'){
      
      //push the bud variable into the array
      options.push(bud);
    }
    if (Checkbox_A[i].value === 'Operation'){
      options.push(op);
    }
    if(Checkbox_A[i].value === 'Employee'){
      options.push(emp);
    }
    
  }
  
  //if there is more then 1 item in options array
  if (options.length > 1) {
    
    //push non variable into the array
    options.push(non);
  }
  
  //display the variables in the array for the Checkbox B options.
  Checkbox_B.options = options;
}
Output Result

If only one options is selected:

If at least two are selected: