PDA

View Full Version : Form Submit Query



joevelardi
7 Aug 2010, 10:17 PM
On Submitting a form, how do i display the values of each field ? I already have a message box created on success - how do i show information in this message box ?

I already have a validation routine and can pass the parameters to a database.



buttons: [{ text: 'Submit',
handler: function() {
if( myForm.getForm().isValid() ) {
myForm.getForm().submit({
url: '/include/qryLoginValidate.asp',
method: 'POST',
success: function(form, action) { msg(('Succes', 'Successful submit'); },
failure: function(form, action) { msg('Error' , 'An error has occurred!'); }
});
}
}
},{ text: 'Reset',
handler: function() { myForm.form.reset(); }
}]

Condor
8 Aug 2010, 10:17 PM
How would you like to show the values?

Would something simple like this do?

Ext.MsgBox.alert('Success', 'Submitted: ' + Ext.encode(form.getValues()));

joevelardi
9 Aug 2010, 4:16 AM
hi Condor, yes in principle this is what i want to achieve. to give you context on how i've created the form, see code below. Have highlighted in red the area i want to achieve this result.

If i want to obtain the email field, for example, how would this be achieved ?

btw, tried using your code but it did not show any form content.

thanks.



function showForgotPassword () {

var passwordForm = new Ext.form.FormPanel({
xtype: 'form',
bodyStyle: 'padding:8px;',
labelAlign: 'top',
baseCls: 'x-plain',
items:[{ xtype: 'container',
layout: 'column',
defaults: { xtype: 'container' },
items: [{ columnWidth: '70px',
items: [{ baseCls: 'x-plain',
html: '<img src="images/security.png" border="0" style="margin:10px 8px 0 0"></img>' }]
}, { columnWidth: .7,
layout: 'form',
items: [{ xtype : 'textfield',
fieldLabel: 'Email Address',
id: 'forgot-login-email',
anchor: '90%'
}]
}]
}]
});

// Show the Form.
var loginWindow = new Ext.Window({
id: 'forgot-pwd-window',
title: 'Forgot Password',
layout: 'fit',
iconCls: 'key',
height: 170,
width: 300,
items: [ passwordForm ],
buttons: [{ text: 'Submit',
handler: function() {
if( passwordForm.getForm().isValid() ) {
passwordForm.getForm().submit({
url: '/include/qryLoginValidate.asp',
method: 'POST',
success: function(form, action) { msg('Success', 'Email Sent to .. ' ); },
failure: function(form, action) { msg('Error' , 'An error has occurred!'); }
});
}
}
},{ text: 'Reset',
handler: function() { passwordForm.form.reset(); }
}]
});

// Position the Login Window and Show
loginWindow.setPosition(screenX, screenY).show();

Condor
9 Aug 2010, 4:42 AM
You could use:

'Email sent to ' + Ext.getCmp('forgot-login-email').getValue()

joevelardi
9 Aug 2010, 5:23 AM
Condor, if i use a simple alert


alert(Ext.getCmp("forgot-login-email"));

the Alert dialog specifies this value as [object Object]

joevelardi
9 Aug 2010, 6:16 AM
Condor, tried using your code but received a firebug error;


Ext.getCmp("forgot-login-email") is undefined

Condor
9 Aug 2010, 6:27 AM
You specified id:'forgot-login-email' for the textfield, so it should exist.

ps. alert(Ext.getCmp("forgot-login-email")); should indeed show [object Object] (read post #4 again and see what you missed).

joevelardi
9 Aug 2010, 6:38 AM
Thx Condor .. got it working.