jQuery and PHP suggested answers

后端 未结 5 2024
谎友^
谎友^ 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 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.

提交回复
热议问题