PDA

View Full Version : How to pass the field value of a form field in another form



lpastor
26 Aug 2009, 8:17 AM
Hello,

The user fills out a form, click on the button NEXT and complete a second form.

I would like the value of a field in the first form is transmitted to the second.

I tried to implement it on the button NEXT :



var cardNav = function(incr){
var l = Ext.getCmp('card-wizard-panel').getLayout();
var i = l.activeItem.id.split('card-')[1];
var next = parseInt(i) + incr;
l.setActiveItem(next);
Ext.getCmp('card-prev').setDisabled(next==0);
Ext.getCmp('card-next').setDisabled(next==2);
Id_Contact = Ext.getCmp('id_contact').getValue();
Ext.MessageBox.alert('Info','toto='+Id_Contact);
Ext.getCmp('id_contact_demande').setValue(Id_Contact); // Error Is Undefined
};

var cardWizard = {
id:'card-wizard-panel',
layout:'card',
activeItem: 0,
bodyStyle: 'padding:15px',
defaults: {border:false},
bbar: ['->', {
id: 'card-prev',
text: '« Précédent',
handler: cardNav.createDelegate(this, [-1]),
disabled: true
},{
id: 'card-next',
text: 'Suivant »',
handler: cardNav.createDelegate(this, [1])
}],
items: [{
id: 'card-0',
items: [gridForm1] // First form
},{
id: 'card-1',
items: [gridForm2] // Second form
}]
};

After that I tried an other solution on the form 2 :


var gridForm2 = new Ext.FormPanel({
frame: true,
width:650,
labelAlign: 'left',
layout: 'column',
items: [{
xtype: 'fieldset',
labelWidth: 90,
defaultType: 'textfield',
autoHeight: true,
border: false,
listeners: {
afterlayout: function(g){
Id_Contact = Ext.getCmp('id_contact').getValue();
Ext.getCmp('id_contact_demande').setValue(Id_Contact); // Error is undefined
Ext.MessageBox.alert('Info2','value='+Id_Contact);
}
},
items: [
{name:'id_demande', width:30, hidden:false, allowBlank: true},
{name:'id_contact_demande', width:30, value:Id_Contact, hidden:false, allowBlank: true},
...
...