syed mhamudul hasan akash syed mhamudul hasan akash - 1 year ago 96
Javascript Question

Drop down list value and text in teleric autocomplete

I have a dropdown list with simple auto complete from teleric UI.I simply want to get text and value from dropdown list by jQuery.But it is not working .
Here is the code

<html xmlns="">
<head runat="server">
<meta charset="utf-8" />
<title>Kendo UI Snippet</title>
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
<link rel="stylesheet" href="" />
<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>
<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>
<form id="form1" runat="server">
<%--<input id="autocomplete" />
--%> <<asp:DropDownList ID="autocomplete" runat="server" ClientIDMode="Static">

<script type="text/javascript">
$(function () {
var data = [
{ id: 1, name: "Apples" },
{ id: 2, name: "Oranges" }
dataTextField: "name", // The widget is bound to the "name" field
dataSource: data
$('#autocomplete').on('change', function() {
var autoCompleteValue = $('#autocomplete').val();
var autoCompleteText = $('#autocomplete').text();
alert(autoCompleteValue + '->' + autoCompleteText);


I want to get value and text when i change the dropdown list.say i select Apples

i want

autoCompleteValue = "1";
autoCompleteText = "Apples";

Answer Source

You can slightly modify your code to achieve your solution:

<input id="autocomplete" />
<div id="result"></div>

    dataTextField: "name",
    select: function(e) {
        var dataItem = this.dataItem(e.item.index());            
        //output selected dataItem
        $("#result").html(kendo.stringify(dataItem)); // Bind html to see your selected text and value      
    dataSource: {
        data: [
            { name: "Apples", value: 1 },
            { name: "Oranges", value: 2 },
            { name: "Bananas", value: 3 },
            { name: "Mangos", value: 4 }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download