Using the properties of the instance manager to control subforms

This example demonstrates how to use the properties of the instance manager (which is part of the XML Form Object Model) to retrieve information about subforms at run time.

In the following form, the four buttons provide information about Subform1 by using the instance manger’s scripting properties. For example, when the form filler clicks the Max button, a message describing the allowed maximum number of supported Subform1 instances appears.

Scripting for the message box to output the value of the count property

The following script uses the messageBox method to output the value of the count property:

    xfa.host.messageBox("The current number of Subform1 instances on the  
    form is:" + properties.Subform1.instanceManager.count, "Instance Manager 
    Properties",3);

You can also write this script by using the underscore (_) notation to reference the count property of the instance manager, as shown here:

    xfa.host.messageBox("The current number of Subform1 instances on the form 
    is: " + properties._Subform1.count, "Instance Manager Properties", 3);

The underscore (_) notation is especially important if no subform instances currently exist on the form.

Scripting for the message box to output the value of the max property

The following script uses the messageBox method to output the value of the max property:

    xfa.host.messageBox("The maximum number of instances allowed for Subform1 
    is: " + properties.Subform1.instanceManager.max, "Instance Manager 
    Properties", 3);

You can also write this script by using the underscore (_) notation to reference the max property of the instance manager, as shown here:

    xfa.host.messageBox("The maximum number of instances allowed for Subform1 
    is: " + properties._Subform1.max, "Instance Manager Properties", 3);

Scripting for the message box to output the value of the min property

The following script uses the messageBox method to output the value of the min property:

    xfa.host.messageBox("The minimum number of instances allowed for Subform1 
    is: " + properties.Subform1.instanceManager.min, "Instance Manager 
    Properties", 3);

You can also write this script by using the underscore (_) notation to reference the min property of the instance manager, as shown here:

    xfa.host.messageBox("The minimum number of instances allowed for Subform1 
    is: " + properties._Subform1.min, "Instance Manager Properties", 3);

Scripting for the message box to output the name of the subform property

The following script uses the messageBox method to output the name of the subform property:

    xfa.host.messageBox("The name of the subform using the instance manager name 
    property is: " + properties.Subform1.instanceManager.name + 
    ".\n\nNote: This value is different than the value returned by the name 
    property for the Subform1 object." , "Instance Manager Properties", 3);

You can also write this script by using the underscore (_) notation to reference the name property of the instance manager, as shown here:

    xfa.host.messageBox("The name of the subform using the instance manager name 
    property is: " + properties._Subform1.name +  
    ".\n\nNote: This value is different than the value returned by the name  
    property for the Subform1 object." , "Instance Manager Properties", 3);

// Ethnio survey code removed