1 Reply Latest reply on Apr 25, 2012 7:56 AM by k9mikep1

    Add/Remove instance(s) within dynamic subform while preserving data

    k9mikep1

      Ok, here is my issue:

       

      I have a form which I use to collect data from other employees throughout my organization. One of the questions requires the user to enter a number between 0-10. If the user enters the number 1, a hidden subform with 10 questions (Subform2) appears right below it. If the user enters the number 2, the subform containing the 10 questions appears right below it twice, and so on. If the user goes back and types 0 (zero) into the box, the subform with the 10 questions becomes hidden.

       

      My question is, if the user enters the number 1 and fills out the following 10 questions and then decides to change the number from 1 to number 2 or 3, the [10 questions] which the user just finished is cleared and the corresponding number of instances are displayed. How can I get the form to add instances or remove instances but keep the data that they have already typed?

       

      In the Exit event of form1.page1.Subform1.TextField5, I have the code:

       

      page1._Subform2.setInstances(0);

      var numStr = this.rawValue;

      for (var i=1; i <= numStr; i++) {

      page1._Subform2.addInstance();

       

         

      }

       

      Any assistance would be greatly appreciated.