PDA

View Full Version : Send combobox vaalue to PHP



Teresh
23 Jul 2012, 10:15 PM
I use PHP and ExtJS.
How I can get in php code selected value in combobox. I need to get id of the selected record.

combo.js

Ext.onReady(function(){
Ext.QuickTips.init();

var countryField = new Ext.form.ComboBox({
hiddenName: 'name',
store: new Ext.data.SimpleStore({
fields: ['id_country', 'name'],
proxy: new Ext.data.HttpProxy({
url: 'form.php'
})
}),
displayField: 'name',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Choose country...',
selectOnFocus:true,
renderTo:'combo_el',
width: 150,
id: 'country-combo',
listeners: {
'select': function(){
//TODO
}
}
});
});

Farish
23 Jul 2012, 10:42 PM
you can use the getValue() method of the combobox in ExtJS:


var value = countryfield.getValue();

This will give you the value of the valueField you use for your combobox and then you can pass it to your PHP.

scottmartin
24 Jul 2012, 9:09 AM
You can send it as a param in ajax.request(), or it should be sent if you submit form.

Scott.

delusion
24 Jul 2012, 12:08 PM
I"m doing something similar where my form has a combobox


var cmbSingleOfficer = Ext.create('Ext.form.ComboBox', { id:'cmbSingleOfficer'
,name:'officer'
,hiddenName:'badge'
,triggerAction:'all'
,width:300
,emptyText:'Select an Officer...'
,store:storeOfficers
,displayField: 'display'
,valueField: 'op_code'
,typeAhead:true
,hideTrigger:true
});

and I check the officerStore and it shows the op_codes and display and names as expected, but when i submit the form, it is submitting the 'display' (which is the displayField) rather than 'op_code' (which is the valueField)