I have a problem with the following javascript:
var stereo_form =new Ext.form.FormPanel({
id: "stereoInfo_panel",
autoDestroy:true,
frame: true,
width: 410,
items:[{
xtype: 'textfield',
fieldLabel: 'DEM Resolution',
name: 'resolution',
value: '0.005' //sets a default value
},{
xtype: 'textfield',
fieldLabel: 'Pyramid Level',
name: 'matching',
value: '0' //sets a default value
},{
xtype: 'textfield',
fieldLabel: 'Size of DEM',
name: 'size',
value: '50.00' //sets a default value
}],
buttons: [{
text: 'Confirm',
handler: function()
{
// user1 = value of resolution field
// user2 = value of matching field
// user3 = value of size field
w.close();
}
}]
});
var w =new Ext.Window({
id: "stereoInfo_win",
title: "Stereo Reconstruction Parameters",
layout: 'form',
height: 152,
width: 415,
items: stereo_form
});
So I need the three user1, user2 and user3 variables to be assigned the values from the form fields resolution, matching and size when the 'confirm' button is pressed, how do I do this?
James
Try this:
var w = new Ext.Window({
id: "stereoInfo_win",
title: "Stereo Reconstruction Parameters",
layout: 'form',
height: 152,
width: 415,
items: {
xtype: 'form',
id: "stereoInfo_panel",
frame: true,
width: 410,
items:[{
xtype: 'textfield',
fieldLabel: 'DEM Resolution',
name: 'resolution',
value: '0.005' //sets a default value
},{
xtype: 'textfield',
fieldLabel: 'Pyramid Level',
name: 'matching',
value: '0' //sets a default value
},{
xtype: 'textfield',
fieldLabel: 'Size of DEM',
name: 'size',
value: '50.00' //sets a default value
}],
buttons: [{
text: 'Confirm',
handler: function(btn)
{
// console.log(Ext.getVersion()); // uncomment to know your extjs version
// traverse to the form object, then get the fields values
var values = btn.findParentByType('form').getForm().getValues();
user1 = values['resolution'];
user2 = values['matching'];
user3 = values['size'];
// traverse up again to the window object
btn.findParentByType('window').close();
}
}]
}
});