Ajax autocomplete show at top of input field năm 2024

Is it possible to have a database with -for example- cities, and as the user types in his/her city, results are fetched from the database and the input box shows a list with possible choices?

Maybe eForm has something like that? Sorry, I did not have the opportunity to try out eForm yet, been busy with trying out a lot of other stuff first!

Anyway, I’d like to know.

  • *
  • 194 Posts you could do this best with some ajax. if you’re using a javascript framework like jquery, google ’jquery autocomplete’. you’ll need to modify the ajax php script they provide to interface with your db table (see ajaxsearch for an example of how to do this). if ajax is beyond you, see: http://www.pengoworks.com/workshop/jquery/autocomplete.htm you could prefill the array with a template variable
  • *
  • 139 Posts Thanks. And thank you for the workshop link as well. Yeah, Ajax is still somewhat beyond me. Actually, it’s another reason why I find Modx so useful... I can use Ajax plug-ins without having to know too much about Ajax internals. Provided they’re available of course.
  • * MODX Staff
  • 10,725 Posts I actually just implemented this autocomplete on a MODx site the other day (it’s private/secure or I’d show you). Might be worth looking at though... http://www.brandspankingnew.net/specials/ajax_autosuggest/ajax_autosuggest_autocomplete.html
  • *
  • 2,204 Posts Quote from: OpenGeek at Apr 03, 2007, 03:45 PM
    I actually just implemented this autocomplete on a MODx site the other day (it’s private/secure or I’d show you). Might be worth looking at though...

http://www.brandspankingnew.net/specials/ajax_autosuggest/ajax_autosuggest_autocomplete.html Could you post the snippet that produces the xml or json file? Dimmy

MODX Staff 10,725 Posts

Sure, though, as you’ll see, this snippet is authored against a custom xPDO data model (xPDOAdmin extends xPDO and encapsulates the connection to the database), and might have some PHP 5 only syntax, though that could be easily remedied. Ok, one step further and now lost in space. I can call the auto complete in my add/edit page if it is not set as "pop up". However, if I set add/edit as a pop up, jquery seams not to send the code. In normal view, I can see via firebug following code at the end of the page:

Put with pop up I miss these lines. I have no idea, what I have to change. Any help? My code: Add page / two php snippet: `echo ' ';

`echo '

';

How do you add autocomplete to input field?

Create an Autocomplete Form.

.
. .
. .
.

What is autocomplete in jQuery?

Autocomplete, when added to an input field, enables users to quickly find and select from a pre-populated list of values as they type, leveraging searching and filtering.

How do I get the selected value from autocomplete?

The AutoComplete control supports strongly-typed HTML helpers represented by lambda expressions that have model or template passed into the View. So, you can get the selected value from view in the Controller part. To achieve this, create an AutocompleteFor control and bound the dataSource from controller part.

What is autocomplete in Ajax?

Ajax Autocomplete for jQuery allows you to easily create autocomplete/autosuggest boxes for text input fields. It has no dependencies other than jQuery.