jQWidgets Forums
jQuery UI Widgets › Forums › Editors › Input, Password Input, TextArea, ColorPicker, Rating, TagCloud, Loader › How To get selected label's value onSelect using jqxInput › Reply To: How To get selected label's value onSelect using jqxInput
Hello samratsaha2,
Please, find the following example which shows how to get item value and item label. If this does not help, please provide us with more information.
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxinput.js"></script>
</head>
<body class='default'>
<div id='content'>
<script type="text/javascript">
$(document).ready(function () {
var timer;
$("#input").jqxInput({
placeHolder: "Enter a City", height: 25, width: 200,
source: function (query, response) {
var dataAdapter = new $.jqx.dataAdapter
(
{
datatype: "jsonp",
datafields:
[
{ name: 'countryName' }, { name: 'name' },
{ name: 'population', type: 'float' },
{ name: 'continentCode' },
{ name: 'adminName1' }
],
url: "http://api.geonames.org/searchJSON",
data:
{
featureClass: "P",
style: "full",
maxRows: 12,
username: "jqwidgets"
}
},
{
autoBind: true,
formatData: function (data) {
data.name_startsWith = query;
return data;
},
loadComplete: function (data) {
if (data.geonames.length > 0) {
response($.map(data.geonames, function (item) {
return {
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
value: item.name
}
}));
}
}
}
);
}
});
$('#input').on('select', function (event) {
var item = event.args.item;
alert('value: ' + item.value + " , " + "label: " + event.args.label);
});
});
</script>
<input type="text" id="input" />
</div>
</body>
</html>
Best Regards,
Nadezhda
jQWidgets team
http://www.jqwidgets.com/