Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Jquery Autocomplete

Jquery Autocomplete

Scheduled Pinned Locked Moved JavaScript
javascriptquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fififlowertot
    wrote on last edited by
    #1

    Hi, I have a dropdown list populated with the list of names on my aspx page. I want to use this as a data source for autocomplete in the name textbox. Which is the best way to do it in jquery?! Thanks,

    N 1 Reply Last reply
    0
    • F fififlowertot

      Hi, I have a dropdown list populated with the list of names on my aspx page. I want to use this as a data source for autocomplete in the name textbox. Which is the best way to do it in jquery?! Thanks,

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      The best way is to read the documentation http://docs.jquery.com/Plugins/autocomplete[^]


      I know the language. I've read a book. - _Madmatt

      F 1 Reply Last reply
      0
      • N Not Active

        The best way is to read the documentation http://docs.jquery.com/Plugins/autocomplete[^]


        I know the language. I've read a book. - _Madmatt

        F Offline
        F Offline
        fififlowertot
        wrote on last edited by
        #3

        I 've tried the following:

        <script type ="text/javascript">
        $(document).ready(function() {
        var a = $("input#names").val();

                $("#tags").autocomplete({
                    url: "CodeFile1.cs\\SearchNames",
                    data: $("input#names").val()
                });
                	    });
        </script>
        

        <div class="ui-widget">
        <label for="names">Names: </label>
        <input id="names" />
        </div>

        and my codefile is :

        public string[] SearchNames(string Name)
        {
        string [] Names = null;
        int i;
        i = 0;
        ServiceClient serviceClient = new ServiceClient();
        SearchResponse searchResponse = new SearchResponse();
        principalSearchResponse = bondInformationServiceClient.SearchPrincipals(principalSearchRequest);

                       foreach (Name name in SearchResponse.NameList)
                {
                    Names \[i\] = name .nameField.ToString().Trim();
                    i++;
                }
            }
        
        
            return Names ;
        }
        

        gives me an runtime error: object expected.

        G 1 Reply Last reply
        0
        • F fififlowertot

          I 've tried the following:

          <script type ="text/javascript">
          $(document).ready(function() {
          var a = $("input#names").val();

                  $("#tags").autocomplete({
                      url: "CodeFile1.cs\\SearchNames",
                      data: $("input#names").val()
                  });
                  	    });
          </script>
          

          <div class="ui-widget">
          <label for="names">Names: </label>
          <input id="names" />
          </div>

          and my codefile is :

          public string[] SearchNames(string Name)
          {
          string [] Names = null;
          int i;
          i = 0;
          ServiceClient serviceClient = new ServiceClient();
          SearchResponse searchResponse = new SearchResponse();
          principalSearchResponse = bondInformationServiceClient.SearchPrincipals(principalSearchRequest);

                         foreach (Name name in SearchResponse.NameList)
                  {
                      Names \[i\] = name .nameField.ToString().Trim();
                      i++;
                  }
              }
          
          
              return Names ;
          }
          

          gives me an runtime error: object expected.

          G Offline
          G Offline
          Gerben Jongerius
          wrote on last edited by
          #4

          I think you read the documentation on the autocomplete plugin wrong. If you wish to use an Url to load the autocomplete data from, which for as far as I've been able to figure out by your sample code you are, then you should return a plain text response with one possible word per line. And keep in mind it performs a round trip to the server, which means you will need to create a script file on the server (JSP, PHP, ASPX). Look at http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions[^] The documentation indicates the call to the server will contain the word to autocomplete in a parameter called 'q'.

          F 1 Reply Last reply
          0
          • G Gerben Jongerius

            I think you read the documentation on the autocomplete plugin wrong. If you wish to use an Url to load the autocomplete data from, which for as far as I've been able to figure out by your sample code you are, then you should return a plain text response with one possible word per line. And keep in mind it performs a round trip to the server, which means you will need to create a script file on the server (JSP, PHP, ASPX). Look at http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions[^] The documentation indicates the call to the server will contain the word to autocomplete in a parameter called 'q'.

            F Offline
            F Offline
            fififlowertot
            wrote on last edited by
            #5

            Thanks Gerben, I read it again and understood what u mean!!.. I was just wondering if it's possible to use a wcf with it? Also since this wcf is being used extensively and returns an object which is a list thanks,

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups