PDA

View Full Version : how use listener function with combobox



fother
5 Feb 2008, 4:13 PM
when i select any country i need make alert of the value of the option choosen..
its possible?



<select NAME="Country">
<option VALUE="USA">United States
<option VALUE="CA">Canada
</select>


the problem isnt the ext component.. but how use the listener function..
i use this but haven't success

countryField is the name of my component


countryField.on('select', function(record, index) { alert(value); });

sfwalter
5 Feb 2008, 6:12 PM
FYI--According to the docs, the select listener is passed 3 objects: combo itself, record object, index.

But this is a better way to handle listeners:



var myCombo = new Ext.form.ComboBox({
listeners: {
select: function(combo, record, index) {
//write cool code here
}
}
})

scott.

fother
6 Feb 2008, 4:19 AM
ok.. but i need do one alert of the value that i select in combo


var myCombo = new Ext.form.ComboBox({
listeners: {
select: function(combo, record, index) {
alert(combo.getValue()); // Return Unitad States and no USA
}
}
});

fother
6 Feb 2008, 4:32 AM
http://extjs.com/learn/Tutorial:Linked_Combos_Tutorial_for_Ext_2

solved

rfmq90
29 Sep 2014, 2:45 AM
I've multiple combobox through my page which I create using the same piece of code, but I just want to use the listener in one.

His function is to when I select a combobox option, I will get the values to populate the combo box right below it.

How can I do it?