从TextField取值的问题

jmajia 2008-06-12

var loginform2 = new Ext.form.FormPanel({
baseCls: 'x-plain',
width:320,
height:150,
layout:'absolute',
border: true,
defaultType: 'textfield',

items: [{
x: 25,
y: 15,
xtype: 'label',
text: '帐 号:'
},{
x: 100,
y: 15,
id:'back_username',
name: 'back_username',
anchor:'95%' // anchor width by %
},{
x:25,
y:52,
xtype: 'label',
text: '密 码:'
},{
x: 100,
y: 52,
id:'back_password',
inputType:'password',
name: 'back_password',
anchor:'95%' // anchor width by %
},{
// The button is not a Field subclass, so it must be
// wrapped in a panel for proper positioning to work
xtype: 'panel',
border: false,
x: 120,
y: 84,
items: [{
xtype: 'button',
width:80,
id:'back_login',
text: '登录',
handler: function(){
alert(Ext.getCmp('back_username').value);

//当在界面中输入相应值得时候,点击登录按钮,提示undifind

//而如果在alert(Ext.getCmp('back_username').value); 之前加一句,

//Ext.getCmp('back_username').setValue("hello");再点击,就可以输出 hello

//为什么不能直接取出值呢
}
}]
}]
});

 

请大家帮我看看是为什么?

upup1000 2008-06-12
应该访问其方法getValue()而不是属性value。改成
alert(Ext.getCmp('back_username').getValue());试一试
Global site tag (gtag.js) - Google Analytics