jQuery ListBox
Set the displayMember property of the jqxListBox. Author: http://jqwidgets.com
by jqwidgets
HTML
<link rel="stylesheet" href="http://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="http://jqwidgets.com/public/jqwidgets/styles/jqx.energyblue.css">
<script src="http://jqwidgets.com/public/jqwidgets/jqx-all.js"></script>
<div id='jqxListBox'></div>
<div id="log"></div>
JavaScript
var data = [{
text: "Affogato",
label: 0
}, {
text: "Americano",
label: 1
}, {
text: "Bicerin",
label: 2
}, {
text: "Breve",
label: 3
}, {
text: "Café Bombón",
label: 4
}, {
text: "Café au lait",
label: 5
}, {
text: "Caffé Corretto",
label: 6
}, {
text: "Café Crema",
label: 7
}, {
text: "Caffé Latte",
label: 8
}, {
text: "Caffé macchiato",
label: 9
}, {
text: "Café mélange",
label: 10
}, {
text: "Coffee milk",
label: 11
}, {
text: "Cafe mocha",
label: 12
}];
var source = {
localdata: data,
datafields: [{
name: "text"
}, {
name: "value",
map: "label"
}]
}
var adapter = new $.jqx.dataAdapter(source);
// Create a jqxListBox
$("#jqxListBox").jqxListBox({
source: adapter,
theme: 'energyblue',
width: '200px',
height: '250px',
displayMember: 'text',
selectedIndex: 0,
valueMember: 'label'
});
$("#jqxListBox").on('change', function(event) {
$("#log").html("label: " + event.args.item.label + ", value: " + event.args.item.value);
});