-
20 Feb 2009 10:48 AM #1
cannot read values from a textfield
cannot read values from a textfield
Hi,
i am frustrated
I wrote the code for logging in and it works so far. but you know what? I can't read values from my textfields "username" and "password". I tried a thousand ways, read the api, search for examples, but it seems this problem is so ridiculous, nobody really cares.
Please help me.
PHP Code:Ext.onReady(function(){
createWindow(450,250,"Bitte loggen Sie sich ein.");
})
function createWindow(p_width, p_height, p_title){
var win = new Ext.Window({
width: p_width,
height: p_height,
resizable: true,
maximizable: true,
title: p_title,
modal: true,
items:[{
xtype:'form'
,id:'testform'
,defaultType:'textfield'
,frame:true
,defaults:{anchor:'95%'}
,items:[
{
html:'<img src="images/icon_lock.png" width="40" height="40" />'
,height:50
,xtype:'panel'
},
{
fieldLabel:'Username'
,id:'username'
},
{
fieldLabel:'Password'
,id:'password'
}
]
,buttons:[
{
buttonAlign: 'right',
text: "Login",
handler: function(){
Ext.Msg.alert("blA",testform.findField("username").getValue());
//utilities.login("http://localhost/ext/starter/login.php",{"loginUsername":
"f", "loginPassword": "password"})
}
},
{
buttonAlign: 'right',
text: "Abbrechen",
handler: function(){
Ext.Msg.alert("Abbruch", "Login wurde abgebrochen");
}
}
]
}]
})
win.show();
}
-
20 Feb 2009 10:52 AM #2
field.getValue() or form.getForm().getValues() should return the values. Also, specifying a name attribute on the field is customary.
-
20 Feb 2009 10:56 AM #3
I doubt you tried a thousand ways.
What have you found via debugging? Set a breakpoint in the handler and inspect the variables. Stop debugging with alerts - you have to step thru the code.Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
20 Feb 2009 11:20 AM #4
uh, u doubt it? really? if so then yes, u are right, i just tried 999 times

anyway, how could I debug, if I am simply don't know, how I can reach that element? I know what debugging is and trust me, I wouldn't ask u such a question, if I did'nt try this already.
Chriz
-
20 Feb 2009 11:44 AM #5
Ext.getCmp('username').getValue();
Ext.get('username').dom.value = ''
choose one.
Also, check out login examples using Ext.Ajax.request instead of form.submit()
you may have to set up params as well.
var params = 'username:' + Ext.getCmp('username').getValue();
then, on your request, just put in the params variable.


Reply With Quote