PDA

View Full Version : how to get the values of the textbox from panel



arunkumargm1987
22 Jun 2010, 4:33 AM
var fsf = new Ext.FormPanel( {
labelWidth :75, // label settings here cascade unless overridden
url :'',
renderTo :'AdvancedSearch',
bodyStyle :'padding:5px 5px 0',
width :945,

items : [
{
xtype :'textfield',
autoHeight :true,
width :400,
fieldLabel :'Search',
name :'txtSearch',
allowBlank :false
},
]
});

and in other js file how can i get the value of 'txtSearch'

arunkumargm1987
22 Jun 2010, 4:44 AM
ple help me

defcon1
22 Jun 2010, 5:00 AM
One way is: Give your textfield an id and then get via Ext.getCmp():



var fsf = new Ext.FormPanel( {
labelWidth :75, // label settings here cascade unless overridden
url :'',
renderTo :'AdvancedSearch',
bodyStyle :'padding:5px 5px 0',
width :945,

items : [
{
xtype :'textfield',
id: 'mytextfield',
autoHeight :true,
width :400,
fieldLabel :'Search',
name :'txtSearch',
allowBlank :false
},
]
});

alert (Ext.getCmp('mytextfield').getRawValue());

defcon1
22 Jun 2010, 5:03 AM
The other way (what I would prefer):



var mytextfield = new Ext.form.TextField({
autoHeight :true,
width :400,
fieldLabel :'Search',
name :'txtSearch',
allowBlank :false
});

var fsf = new Ext.FormPanel( {
labelWidth :75, // label settings here cascade unless overridden
url :'',
renderTo :'AdvancedSearch',
bodyStyle :'padding:5px 5px 0',
width :945,

items : [
mytextfield
]
});

alert (mytextfield.getRawValue());

arunkumargm1987
22 Jun 2010, 5:06 AM
Hi defcon1,

I need to use the value of txtSearch field in another js file. how can it be done ?

defcon1
22 Jun 2010, 5:26 AM
It doesn´t matter in what file the textfield is defined, as long as you have the correct
include-order. All js-files have to be included in the page and so they´re all in the same
context.

Without knowing your application I can´t give you any hints, but try to access the
textfield via the object-model and if you´re not able to, try to give it a unique id
and access it via the DOM.