Hey I am working on Custom php project of directory listing. in listing page i need to add one autocomplete (for directory Keywords) with multiple selection and also accept new inserted keyword by User. Is there any body for reference..?
same autocomplete like this site as we insert new tags in stack.O.F
There are two parts needed:
Regarding the first part, you can use something like
$("#keywords").autocomplete({
source: function(request, response) {
$.getJSON( "search.php", {
term: request.term.split(/,\s*/).pop()
}, response );
},
search: function() {
var term = this.value.split(/,\s*/).pop();
if (term.length() < 2) {
return false;
}
}
});
For a more complete example, refer to https://jqueryui.com/autocomplete/#multiple-remote.
On the other hand, the second part cannot be done on the client side. Instead, you need to split the keyword list on the server side and check for each keyword, whether it is already known, creating it, if not. Assuming you identify keywords using integer IDs in the database and you need to get the IDs for creating many-to-many relationships, you can perform that when you get the IDs from the database.