Welcome Guest, Not a member yet? Register   Sign In
help with autocomplete text input
#1

hello, please help with autocomplete input text with reference to a database
Reply
#2

Hi.

You can use jQuery UI Autocomplete.

http://jqueryui.com/autocomplete/#remote
Reply
#3

I would like some codeigniter MVC example, I have made many tests but none have worked for me so far
(05-28-2015, 08:28 PM)jeromi Wrote: hello, please help with autocomplete input text with reference to a database
Reply
#4

It's pretty easy.

There's an ajax request that gets fired when someone is typing in an input box. The ajax request sends the content of the input box to a controller. The controller does a db lookup and pulls data that is LIKE '$input%', and returns a json object back to your javascript, which then populates the dropdown with matching choices.

There isn't really anything that has to do with CI or MVC here. You're making a request to a controller and returning data, just like anything else. The only difference is you have javascript making the request via ajax.

If you would like help with your existing code, post it and I'm sure someone can point you in the right direction with whatever you're having a problem with.
Reply
#5

Alternatively, depending on the amount of data you're dealing with, you can supply the possible values for the field in the original response and have the auto-complete functionality entirely handled on the client: http://jqueryui.com/autocomplete/#multiple

The biggest issue you have to look out for in dealing with almost any auto-complete solution in CI is handling AJAX functionality when CSRF protection is enabled on the site, because you have to ensure that you can send the CSRF field/value in the POST, and possibly update the CSRF field/value when sending/handling the response.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB