title: How to get user input value from Ext window textfield?
body: <p>I have a webpage with buttons designed in Extjs. When the user clicks 1 of these buttons, a window appears with a textfield and a next button. Clicking the next button will load another window with fieldsets, hiding the first one. The number of fieldsets in the second form is to be adjusted according to the user input in the first window. I am trying to use a for loop for this.
  The code I am using as follows:</p>
  
  <pre><code>var win1, win 2, j;
  
  var win1items = new Ext.form.FormPanel({
      //snip
      items: [{
          xtype: 'fieldset',
          defaultType: 'textfield',
          items: [{
              fieldLabel: 'Number',
              allowBlank: false,
              name: 'Number',
              width: 110,
              cls:"txtfield"
          }]
      }],
      buttons: [{
          text: 'Next',
          handler: function(){
              if(!win2){
                  winc2 = new Ext.Window({
                      //snip
                      items: [win2items]
                  });
              }
  
              win2.show(this);
              win1.hide();
          }
      }]
  });
  
  j = Ext.getCmp('win1').getForm().findField("Number").getValue();
  var fldComs = [];
  
  for (i=0; i&lt;=j; i++){
      fldComs[i] =  new  Ext.form.FieldSet({
          //snip
          items: [{
          //snip
          }]
      });
  }
  
  win2items = new Ext.form.FormPanel({
      //snip
      items: [fldComs]
  });
  
  Ext.onReady(function(){
      new Ext.Toolbar({
          renderTo: document.body,
          items: [{
              xtype: 'tbbutton',
              text: 'Start Here',
              cls: 'menu-icon',
              handler: function(){
                  if(!win1){
                      win1 = new Ext.Window({
                          //snip
                          items: [win1items]
                      });
                  }
                  win1.show(this);
              }
          }]
      });
  });
  </code></pre>
  
  <p>The error I am getting is </p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot call method 'getForm' of undefined.</p>
  </blockquote>
  
  <p>However if i am using a fixed value in the for loop, say 5 I am getting the desired output. I am using Ext 3.2.1</p>