Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:09:51+00:00 2026-06-09T07:09:51+00:00

my auto complete is working fine as i can select the text . but

  • 0

my auto complete is working fine as i can select the text . but problem is that i want to get the key value (Id) of selected item . so i can set on hidden field and use server side.

here is my web method code :

[WebMethod]
    public List<string> AuotExtenderHotel(string hotelname)
    {
        DataSet ds = objHotelList.GetHotels(hotelname);
        List<string> result = new List<string>();
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            result.Add(dr["HotelName"].ToString());
        }
        return result;
    }

and here is my jquery autocomplete code

<script type="text/javascript">
    $(document).ready(function () { HotelText(); });
    function HotelText() {
        $(".txthotel").autocomplete({
            source: function (request, response) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "WebService.asmx/AuotExtenderHotel",
                    data: "{'hotelname':'" + $('.txthotel').val() + "'}",
                    dataType: "json",
                    success: function (data) {

                        response(data.d);


                    },
                    error: function (result) {
                        alert("Error");
                    }


                });
            }
        });
    } 
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:09:52+00:00Added an answer on June 9, 2026 at 7:09 am

    How can you expect Id of the item in view if your server is not returning anything other than array of strings? I would modify the web method to return a JSON object which includes objects of ID and value pair. like

    [{ "id": "1", "label": "MyFirstHotel", "value": "MyFirstHotel" },{ "id": "2", "label": "MySecondHotel", "value": "MySecondHotel" }]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to getting auto complete working and i can do so fine when
I was able to get jQuery autocomplete working in CoffeeScript just fine, but when
I'm working on a jQueryMobile application with some form fields that need auto complete
I have installed Eclipse Indigo and the auto-complete feature is working normally in the
I am trying to get autocomplete working working with JQuery UI, but I am
I'm using tokenInput jquery plugin for autocomplete. This script is working fine <script type=text/javascript>
I'm working on a simple auto complete function for my Flex mobile app. For
I have an Ajax autocomplete extender, and it is working fine. However, I want
I have a text box with autocomplete set and working perfectly fine. However when
I've got autocomplete working fine, but I'm trying to figure out way to make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.