PDA

View Full Version : Form Help



pwgustafson
27 Sep 2010, 12:52 PM
How do I access form elements when doing an ajax request?


MY FORM:



demos.GetCustomerRepExtension = new Ext.form.FormPanel({
scroll: 'vertical',
items: [{
xtype: 'fieldset',
title: 'Input Parameters',
instructions: 'Please enter the information above.',
items: [{
xtype: 'textfield',
id: 'search_no',
name: 'search_no',
label: 'Number',
placeholder: 'search_no',

},
{
xtype: 'select',
name: 'search_type',
label: 'Type',
options: [{
text: 'Account',
value: 'ACCOUNT'
},
{
text: 'Phone',
value: 'PHONE'
}]
},
{
xtype: 'select',
name: 'ext_type',
label: 'Type',
options: [{
text: 'Sales',
value: 'SALES'
}]
}
]
},

{
xtype: 'button',
ui: 'action',
text: 'Execute',
handler: buttonHandler

}/]//End Items
});//End Form Panel


MY REQUEST:



var buttonHandler = function(button,event) {
Ext.Ajax.request({
url: 'ajax/ajax_GetCustomerRepExt.php',
params:{
FORM VALUES HERE
},
success: function(response, opts) {
alert(demos.GetCustomerRepExtension.items.items[0]);

}
})
};


What is the best way to get the values of the form fields and pass them through to the AJAX request.

Thanks.

jay@moduscreate.com
27 Sep 2010, 12:53 PM
Why not use the formPanel's submit method?

jay@moduscreate.com
27 Sep 2010, 1:02 PM
... approved thread.

evant
27 Sep 2010, 3:32 PM
Agree, you should use the form panel submit method, it handles all that for you.

tomalex0
27 Sep 2010, 10:17 PM
try this

demos.GetCustomerRepExtension.getValues();

pwgustafson
28 Sep 2010, 9:08 AM
try this

demos.GetCustomerRepExtension.getValues();

Thanks, but not quite sure how to use that?

Do I have to specify which values im trying to get?

For example, if I wanted to grab the value for item "Search Type" how do I specify that?

pwgustafson
28 Sep 2010, 2:12 PM
Why not use the formPanel's submit method?

Thanks, but do you have an example of how I could use this? Your suggestion is appreciated, but not much help without an example.

Thanks.

pwgustafson
28 Sep 2010, 2:13 PM
Thanks, but do you have an example of how I could use this? Your suggestion is appreciated, but not much help without an example.

Thanks.

evant
28 Sep 2010, 2:55 PM
http://dev.sencha.com/deploy/touch/docs/?class=Ext.form.FormPanel&member=submit

tomalex0
28 Sep 2010, 11:41 PM
try something like this.



console.log(demos.GetCustomerRepExtension.getValues())

demos.GetCustomerRepExtension.getValues().searchtype;


Any how its better to use Form Submit.
Its already in examples
http://dev.sencha.com/deploy/touch/examples/forms/