<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml"> Code Repository --> <link href = "../extjs/resources/CSS/ext-all.css" rel = "stylesheet" type = "text/CSS"/> <! -- Ext JS (4.0) officially downloaded code library --> <SCRIPT src = ".. /extjs/ext-all.js "type =" text/JavaScript "> </SCRIPT> <SCRIPT type =" text/JavaScript "Language =" JavaScript "> var ST1 = new Ext. data. store ({fields: ["name", "ID"], data: [{name: "male", ID: "1 "}, // If the displayed male is 1 {name: "female", ID: "2"} // If the displayed female is 2]}); Ext. onready (function () {var W = new Ext. window ({Height: 500, width: 500, title: "drop-down list control", items: [{xtype: "ComboBox", store: ST1, displayfield: "name ", // name valuefield: "ID" is displayed, // The value is ID fieldlabel: "gender", // label labelwidth: 50, // label width Editable: false, // emptytext cannot be edited: "select... ", // The text ID displayed when it is null:" cbosex ", // ID listeners: {// listen for events, except click events, other events are written here in select: function (C, B) {// select the event alert (ext. getcmp ("cbosex "). getvalue (); // here the ID is obtained}]}); W. show () ;}); </SCRIPT>
The effect preview is as follows: