Recently looked at ExtJS, before on this aspect did not study, only therefore did not study, heard others said this frame to occupy the memory, recently spent a few days in the study this, feels good. If it is done simply, construction with Easyui
var st1 = new Ext.data.Store ({fields: ["Name", "id"], data: [{n Ame: "Male", ID: "1"}, {name: "female", ID: "2"}]}); var w = new Ext.window ({height:500, width:500, Title: "Drop-down list control", Items: [ {xtype: "ComboBox", Store:st1, Displayfield: "Name ",//display is name Valuefield:" id ",//value is ID Fieldlabel:" Gender ",//label labelwidth:50,//label width editable:false,//non-editable empt Ytext: "Please select ...",//is empty when the text ID is displayed: "Cbosex",//id listeners: {/ /listen events, except for click events, all other events are written here Select:function (c, b) {//Select event alert (ext.getc MP ("Cbosex"). GetValue ()); I got the ID here. } } } ] }); W.show ();
var combo = new Ext.form.ComboBox ({ emptytext: ' Please select Shanxi City ', mode: ' Local ', width:100, triggeraction: ' All ', transform: ' Combo ' }); var btn = new Ext.button ({ text: "list box value", renderTo:Ext.getBody (), handler:function () { Ext.Msg.alert ("City", "Actual value:" + combo.getvalue () + "; Display value:" + combo.getrawvalue ()); } );
<select id= "combo" class= "center" > <option value= "Dalian" > Taiyuan </option> <option value= " Shenyang "> Jincheng </option> <option value=" Dandong "> Changzhi </option> <option value=" Anshan " > Linfen </option> </select>
There are bad places to write, you can always put forward, learn more.