Body
**Checkboxes are treated as arrays in Frevvo.
When you have checkbox controls within repeaters, in your code you are essentially calling on an array (each checkbox control's values} within another array (the repeating checkbox control itself). For rules where an action is dependent on whether a checkbox option is selected or not, use " [i].value[i] " to specify the array from the checkbox values and the array from the repeating checkbox control.
The example below has a Checkbox control (named Checkbox) with the options A, B and C in a repeating Section. If A is selected then text control (named Text) will be become enabled. Because the text control is also in the repeater it also needs the counter [i] to keep track of the instance.
if(Repeat.itemAdded){
i = Repeat.itemIndex;
if(Checkbox[i].value[0] == 'A'){
Text[i].enabled = true;
} else {
Text[i].enabled = false;
}
} else {
for (var i=0; i < Checkbox.value.length; i++){
if(Checkbox[i].value[0] == 'A'){
Text[i].enabled = true;
} else {
Text[i].enabled = false;
}
}
}
|
Outputting Data from Repeating Checkbox to Message box
*This scenario can be used in conjunction with Frevvo emails to include specific data from the form.
|
If you want to create a rule where it outputs the selected Checkbox values into a message box. You will need to utilize nested for loops in your code because you are calling the array for the value(s) of the checkbox and the array for the repeating checkbox control.
The example below has a text control (Name) and a checkbox (Checkbox) inside a repeating section. The code is outputting each Name instance and the select values of the checkbox to the message box.
var string = "";
if(Trigger.clicked) {
// loop for the number times Name control is repeated
for ( var i=0; i < Name.value.length; i++) {
// loop checks arrays for the checkbox values
//notice [i].value is used NOT [z].value
for (var z=0; z < Checkbox[i].value.length; z++){
//saves all the data to the string variable
string += "<br /><b>Name: </b>" + Name[i].value + "<br />" +
"<b>Device: </b>" + Checkbox[i].value[z] + "<br />";
}
}
MsgBox.value = string;
}
/*
use html to make it more pleasing to read:
<br/> = line break
<b> = bold
</b> = bold ends
**/