PDA

View Full Version : How send data from form with comboboxes?



evil_elf
28 Mar 2010, 4:08 AM
Ext.Ajax.request({
url: 'json_data.php?do=user_id',
method: 'POST',
success: function(responseObject){
user_id = responseObject.responseText;
query_form = new Ext.FormPanel({
bodyStyle:'padding:5px 5px 0',
labelWidth: 90,
width: 406,
baseParams: {user_id: user_id},
defaultType: 'textfield',
items: [new Ext.form.ComboBox({
fieldLabel: '??????????',
name: 'company_id',
store: companies_store,
forceSelection:true,
//hideTrigger: true,
minChars: 3,
typeAhead:true,
mode: 'local',
triggerAction: 'all',
width: 300,
displayField:'company_name',
valueField: 'company_id',
emptyText:'???????? ???????????',
renderTo: document.body
//onSelect: function(record){alert(record.company_id)}
}), new Ext.form.ComboBox({
fieldLabel: '????????',
name: 'exhib_id',
store: exhibs_store,
forceSelection:true,
//hideTrigger: true,
minChars: 3,
typeAhead:true,
mode: 'local',
triggerAction: 'all',
width: 300,
displayField:'exhib_name',
valueField: 'exhib_id',
emptyText:'???????? ????????',
renderTo: document.body
//onSelect: function(record){alert(record.exhib_id)}
})],

buttons: [{text: 'Clear', handler: function(){query_form.getForm().reset()}},
{text: 'Save', handler: function(){query_form.getForm().submit({
url:'test.php',
method: 'POST',
success: function(form, action) {Ext.Msg.alert('Success', action.result.msg);},
failure: function(form, action) {if(action.failureType == Ext.form.Action.CONNECT_FAILURE){ Ext.Msg.alert('??????!', '?????????? ??????????? ? ????????');}}});}}]});
query_form.render('query_form');
}});

Hi.I have this functions, where each combox have two parameters: ****_id and ****_name.When i press submit, form sent values from ****_name, but i need send ****_id values of each element.See my store:


companies_store = new Ext.data.JsonStore({
url: 'json_data.php?do=companies_list',
fields: ['company_id', 'company_name'],
autoLoad: true
});

exhibs_store = new Ext.data.JsonStore({
url: 'json_data.php?do=exhibs_list',
fields: ['exhib_id', 'exhib_name'],
autoLoad: true
});


How sent id data from form?

fay
28 Mar 2010, 5:20 AM
See the docs for hiddenName (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.ComboBox&member=hiddenName).

evil_elf
28 Mar 2010, 5:27 AM
fay, in my code iam change valueField: 'company_id' to hiddenName 'company_id' , but is not wokr: script send name, but not id...

fay
28 Mar 2010, 5:43 AM
I'm guessing that you didn't read the docs fully :)


if the ComboBox name and hiddenName are the same, you should specify a unique hiddenId.

Also, don't remove the valueField entry.

evil_elf
28 Mar 2010, 5:59 AM
Iam read it, from start to end, but nothing understand :)

This code work correctly

name: 'company_id',
displayField:'company_name',
hiddenName: 'company_name',
valueField: 'company_id',

but if iam change hiddenName: 'company_name' to hiddenName: 'company_id', its also works!And name: 'company_id' = hiddenName: 'company_id' ! Why?


name: 'company_id',
displayField:'company_name',
hiddenName: 'company_id',
valueField: 'company_id',

tnx :)

fay
28 Mar 2010, 6:05 AM
You know what, I think I mis-read it, or didn't read it all!! :">


The ComboBox id and the hiddenId should be different, since no two DOM nodes should share the same id. So, if the ComboBox name and hiddenName are the same, you should specify a unique hiddenId.

You're not specifying an 'id' for the combobox (which I always do) so your 'name' and 'hiddenName' values being the same shouldn't cause a problem.

tomalex0
28 Mar 2010, 10:49 AM
name: 'company_id',
displayField:'company_name',
hiddenName: 'company_values',
valueField: 'company_id',


if you submit your form , you can see company_values in http header.