jQuery and PHP suggested answers

后端 未结 5 2015
谎友^
谎友^ 2021-01-27 11:15

Hey guys, there is a form where the user select some of his friends and I\'m curious on how I can implement a list that searches simultaneously while the user is typing a friend

相关标签:
5条回答
  • 2021-01-27 11:48

    This what already asked here on this site.

    Facebook style JQuery autocomplete plugin

    The accepted answer cited this jQuery code.

    https://github.com/loopj/jQuery-Tokenizing-Autocomplete-Plugin

    0 讨论(0)
  • 2021-01-27 11:52

    http://jqueryui.com/demos/autocomplete/

    Although think twice about including the whole jquery ui library for this one plugin

    0 讨论(0)
  • 2021-01-27 11:55

    You should take a look at the jquery auto-complete plugin:

    http://docs.jquery.com/Plugins/autocomplete

    Also, you could separate the names using commas.

    0 讨论(0)
  • 2021-01-27 12:02

    Are you looking to write your own plugin or would you like to use an existing one?

    If you want something ready made, here are a few examples

    if you want something extremely light, only 6kb packed, this one would be the best choice
    Autosuggest jQuery Plugin

    Older one but still good

    Tokenizing Autocomplete

    0 讨论(0)
  • 2021-01-27 12:06

    I've implemented this a couple of times, it is not that difficult to achieve decent results and the basic idea that I used was...

    1) create an input box.

    2) create a div positioned directly underneath the input box.

    3) create a jquery keypress handler. if there are more than x characters typed, ajax request.

    4) loop through the results, and if they exist, append result divs to the result box.

    5) show the result box.

    I can dig up some example code if you would like. Not sure what you are talking about with the select multiple, but you could keep a variable of selected, and change the color of the result div when it is clicked on, this way many results can be selected and then processed later.

    0 讨论(0)
提交回复
热议问题