The button triggers a script that uses instanceManager, the XML Form Object Model object that manages the instance creation, removal, and movement of form objects. When the end user deletes the Comment subform, the
instanceManager object removes the subform from both the Form data document object model (DOM) and the Data DOM.
Note that instanceManager uses four methods:
addInstance,
removeInstance,
moveInstance, and
setInstances. The naming convention of an
instanceManager is the subform name prefixed with an underscore (
_subformname). The syntax for
instanceManager is
_subformname.methodname().
_comments.setInstances(1); // Add the comments subform.
this.resolveNode(“caption.value.#text”).value =”Clear Comments”; // Change the button’s caption.
_comments.setInstances(0); // Remove the comments subform.
this.resolveNode(“caption.value.#text”).value = “Add Comments”; // Change the button’s caption.