This example demonstrates how to use the methods of the instance manager (which is part of the XML Form Object Model) to perform operations on subform objects at run time. For example, you can add remove instances of a particular subform, table, or table row.In the following form, the form filler uses the four buttons to use the various instance manager scripting methods. For example, when the form filler clicks the Add button a new Subform2 instance is added to the form.
Note: The Move button reorders the first two Subform2 instances, and the Set button displays the maximum number of Subform2 instances. In both cases, you may need to add or remove subforms, or make changes to the data in the text fields to see the changes applied to the Subform2 instances.The following script determines whether the supported maximum number of Subform2 instances exist on the form. If the maximum number exists, the script displays a message. Otherwise, a new Subform2 instance is added to the form.xfa.host.messageBox(“You have reached the maximum number of items allowed.”,
“Instance Manager Methods”, 1);You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown here:xfa.host.messageBox(“You have reached the maximum number of items
allowed.”, “Instance Manager Methods”, 1);The following script determines whether any Subform2 instances exist on the form. If none exist, the script displays a message indicating that no instances exist. If instances do exist, the script removes the first instance from the form.You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown here:The following script forces four Subform2 instances to appear on the form regardless of how many instances currently exist:You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown here:The following script forces the first and second Subform2 instances to switch locations on the form.You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown here.