I have a webpage with buttons developed in Extjs. When a user clicks on one of these buttons, a window appears with a text box and the next button. Clicking on the next button will load another window using the fields, hiding the first one. The number of fields in the second form should be adjusted in accordance with the user input in the first window. I am trying to use a for loop for this. The code I use as follows:
var win1, win 2, j;
var win1items = new Ext.form.FormPanel({
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({
items: [win2items]
});
}
win2.show(this);
win1.hide();
}
}]
});
j = Ext.getCmp('win1').getForm().findField("Number").getValue();
var fldComs = [];
for (i=0; i<=j; i++){
fldComs[i] = new Ext.form.FieldSet({
items: [{
}]
});
}
win2items = new Ext.form.FormPanel({
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({
items: [win1items]
});
}
win1.show(this);
}
}]
});
});
The error I get is
Uncaught TypeError: Unable to call getForm method from undefined.
However, if I use a fixed value in a for loop, say 5, I get the desired result. I am using Ext 3.2.1
source
share