You can add or remove subform instances by adding calculations or scripts to objects on your form using the Script Editor.
• If it is not already visible, display the Script Editor by selecting Palettes > Script Editor. Expand the Script Editor so that it is displayed in multiline view.
1. Select the object on your form design that you want to add the script to and select an event from the Show list in the Script Editor. For example, choose the click event of a button or other interactive form object.
2. Type one of the following scripts in the Script Editor, where Subform1 is the name of the subform to add instances to, and the value true indicates that the new subform instance should be merged with the form data:xfa.form.recalculate(true) // Invoke the recalculate method to include the field values from the added subform in the form calculations.xfa.form.recalculate(true) // Invoke the recalculate method to include the field values from the added subform in the form calculations.xfa.form.recalculate(true) // Invoke the recalculate method to include the field values from the added subform in the form calculations.xfa.form.recalculate(true) // Invoke the recalculate method to include the field values from the added subform in the form calculations.
1. Select the object on your form design that you want to add the script to and select an event from the Show list in the Script Editor.
2. Type one of the following scripts in the Script Editor, where Subform1 is the name of the subform to remove an instance from and integer is the zero-based index number of the instance to remove:
To add and remove subform instances using scripting