Results 1 to 4 of 4

Thread: Send combobox vaalue to PHP

  1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    2

    Default Send combobox vaalue to PHP

    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
    Code:
    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
                }
            }
        });
    });

  2. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,102
    Answers
    113

    Default

    you can use the getValue() method of the combobox in ExtJS:

    Code:
    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.

  3. #3
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    You can send it as a param in ajax.request(), or it should be sent if you submit form.

    Scott.

  4. #4
    Sencha Premium Member
    Join Date
    Sep 2011
    Posts
    26

    Default

    I"m doing something similar where my form has a combobox

    Code:
    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •