...
Code Block |
---|
Traveler1.visible = false; Traveler2.visible = false; Traveler3.visible = false; Traveler1.required = false; Traveler2.required = false; Traveler3.required = false; for (var i=0; i < NumTickets.value; i++) { if (i >= 0) { Traveler1.visible = true; Traveler1.required = true; } if (i >= 1) { Traveler2.visible = true; Traveler2.required = true; } if (i >= 2) { Traveler3.visible = true; Traveler3.required = true; } } |
Repeat Item Number
You can easily auto populate incremental items numbers in repeats using a business rule. In this example Erepeat is the name of the repeat control and Item is the name of the item control inside the repeat. You also need to set 1 as the default value of first repeating Item control directly into your form field as you're designing your form.
Code Block |
---|
if (Erepeat.itemAdded || Erepeat.itemRemoved){
for(var i = 0; i < Item.value.length; i++) {
Item[i].value = i+1;
}
} |
Tables
Tables are identical to repeat controls when referenced in business rules. Tables are a grid layout of repeating items. All the rule examples in this chapter that discuss repeats apply also to tables. The one important note is that you cannot explicitly name the repeat control inside your table. The repeat control inside a table is automatically named as <TableName>Repeat. For example a table named Expense automatically has a repeat named ExpenseRepeat. The rule ExpenseRepeat.itemAdded and ExpenseRepeat.itemIndex references an item added to your table and that item's index respectively.
...
Code Block |
---|
if (MLrepeat.itemAdded) { var index = MLrepeat.itemIndex; // This rule is fired both when the user clicks "+" // and when frevvo adds items found in the init doc. // Need to assign new mid only when user clicks "+" // New items added via "+" will have a zero length value. if (MLmid[index].value.length === 0) { // Assign unique ID to label so it can be referenced // in RI Mailing Labels field // Count the number of existing mailing labels on the form var maxId = 0; for (var i=0; i < MLmid.value.length; i++) { if (MLmid[i].value > maxId) { maxId = MLmid[i].value; } } var next = parseInt(maxId, 10) + 1; MLmid[index].value = next.toFixed(0); } } |
Repeat Item Increment
You can easily auto populate incremental items numbers in repeats using a business rule. In this example Erepeat is the name of the repeat control and Item is the name of the item control inside the repeat. You also need to set 1 as the default value of first repeating Item control directly into your form field as you're designing your form as shown here.
Code Block |
---|
if (Erepeat.itemAdded || Erepeat.itemRemoved){ for(var i = 0; i < Item.value.length; i++) { Item[i].value = i+1; } } |
Display Uploaded Image
A rule can dynamically display an image uploaded to your form via the upload control. In this example the upload control is named 'u'. The form also must contain a message control as a place holder for displaying the uploaded image. The rule dynamically creates a URL to the uploaded image in the temporary attachment repository. The upload control's value 'u.value' is a GUID that uniquely identifies the attachment.
...