Other versions:

AutoCompleter (v1.1)

Project AutoCompleter Showcase This AutoCompleter script for MooTools provides the functionality for text suggestion and completion. It features different data-sources (local, JSON or XML), a variety of user interactions, custom formatting, multiple selection, animations and much more.

Showcases:

Showcase “Local Tag”

Autocompleted tags in input fields and textareas, controlled by keyboard and mouse.

The Action Happens Here

del.icio.us / search (Suggestions from top tags)

JavaScript & MooTools

document.addEvent('domready', function() {
 
	// Test source, list of tags from http://del.icio.us/tag/
	var tokens = ['.net', '2008', '3d', 'advertising', 'ajax', 'appengine', 'apple', 'architecture', 'art', 'article', 'articles', 'audio', 'blog', 'blogging', 'blogs', 'books', 'business', 'china', 'community', 'computer', 'cooking', 'cool', 'css', 'culture', 'design', 'development', 'diy', 'download', 'education', 'english', 'environment', 'fashion', 'fic', 'film', 'finance', 'firefox', 'flash', 'flex', 'flickr', 'fonts', 'food', 'free', 'freeware', 'fun', 'funny', 'gallery', 'games', 'generator', 'git', 'google', 'government', 'graphics', 'green', 'hardware', 'health', 'history', 'home', 'howto', 'humor', 'illustration', 'imported', 'inspiration', 'interactive', 'internet', 'java', 'javascript', 'job', 'jobs', 'language', 'law', 'library', 'linux', 'mac', 'maps', 'marketing', 'math', 'media', 'microsoft', 'mobile', 'money', 'mp3', 'music', 'news', 'online', 'opensource', 'osx', 'photo', 'photography', 'photos', 'photoshop', 'php', 'politics', 'portfolio', 'productivity', 'programming', 'python', 'rails', 'recipe', 'recipes', 'reference', 'research', 'resources', 'ruby', 'school', 'science', 'search', 'security', 'seo', 'sga', 'shopping', 'slash', 'social', 'software', 'statistics', 'teaching', 'tech', 'technology', 'tips', 'todo', 'tools', 'toread', 'travel', 'tutorial', 'tutorials', 'tv', 'twitter', 'typography', 'ubuntu', 'video', 'visualization', 'web', 'web2.0', 'webdesign', 'webdev', 'wiki', 'windows', 'wordpress', 'work', 'writing', 'youtube'];
 
	// Our instance for the element with id "demo-local"
	new Autocompleter.Local('demo-local', tokens, {
		'minLength': 1, // We need at least 1 character
		'selectMode': 'type-ahead', // Instant completion
		'multiple': true // Tag support, by default comma separated
	});
 
	// Our instance for the element with id "demo-local-2", the textarea
	new Autocompleter.Local('demo-local-2', tokens, {
		'minLength': 1, // We need at least 1 character
		'selectMode': 'type-ahead', // Instant completion
		'multiple': true // Tag support, by default comma separated
	});
 
});

XHTML Markup

<form action="http://del.icio.us/search/" method="get" id="form-demo">
	<fieldset>
 
		<legend><a href="http://del.icio.us/">del.icio.us</a> / search <small>(Suggestions from <a href="http://del.icio.us/tag/">top tags</a>)</small></legend>
		<label>
			<input type="text" name="p" id="demo-local" />
		</label>
 
		<label>
			<textarea name="p_long" id="demo-local-2" style="height: 100px;"></textarea>
		</label>
 
	</fieldset>
</form>

CSS Stylesheet

#demo-local
{
	width:				350px;
	border:				1px solid #444;
}

This example and the accompanying sources/assets are © 2008-2009 by Harald Kirschner and available under The MIT License. For debugging and profiling the scripts and their markup download Firefox and use addons like Firebug and Web Developer Toolbar.

Share it: Stumble it!Digg This!del.icio.us (388 Posts: )

discussion by DISQUS 261 Comments

Please use the support forums for discussing the project, asking questions or posting bug-fixes!

Sort:
Comments 21 – 40 of 261:
  • reply
    Avatar
    elguapo09
    replied 1 year ago (1 Point)
    Hmm, this comment was ment for CroNiX...
  • reply
    Avatar
    replied 1 year ago (1 Point)
    Yeah. I'd like to know if digitarald got a solution for this, just like he said in his reply for CroNiX. Is it possible that AutoCompleter works with a select instead of an input? It would be awesome. Thanks.
  • reply
    Avatar
    said 1 year ago (1 Point)
    Hello. It's a really nice script. Congratulations.
    I was wondering if you got a solution for a <select> autocomplete, like some people were saying. It would be useful to me. Thank you!</select>
  • reply
    Avatar
    Kevin
    said 1 year ago (1 Point)
    Has anyone used this when pulling the auto suggest values from a Mysql db with PHP?
  • reply
    Avatar
    digitarald Site Owner
    replied 1 year ago (1 Point)
    Sample PHP code in the documentation (using PDO), its not that hard ;)
  • reply
    Avatar
    Manuel Jenne
    said 1 year ago (1 Point)
    Harald, first of all: thanx a lot for this great script.

    I'm running a page on ISo 8859-1 and having problems regarding the german umlaute on a Request.HTML.

    For example hitting "nö" is sending "ö" to my php script. the script does the db requests but nothing is found as in the db the entries are "nördlingen" for example. Beside the umlaute the script is working perfect.

    Can you help on this topic? Thanks!
  • reply
    Avatar
    Dima
    replied 1 year ago (1 Point)
    I had the problem with russian letters. The page was in windows-1251 encoding. And the script received value in utf-8 encoding. I used this Perl code:

    Encode::from_to($value, 'utf-8', 'windows-1251');

    And it worked.
  • reply
    Avatar
    Alberto V.
    replied 1 year ago (1 Point)
    hi,

    im having also problems with the encoding using Autocompleter.Request. I've a input text that sends the value for example látex (acute). Then i receive in my java servlet the parameter value l├ít , what its wrong (some king of codec error).

    As i read above, with Autocompleter, its seems to reach to the destination request the parameters in UTF-8, but using conversion to ISO-8859-1 ( new String(value.getBytes("ISO-8859-1"), "UTF-8") ) also dosnt work. Can anyone help me with this?

    windows xp - firefox 3.0.10 - mootools 1.2.2 - autocompleter 1.1.2
  • reply
    Avatar
    Leo_Moon85
    said 1 year ago (1 Point)
    Hi,
    I had implemented autocompleter control.
    But I need control work like facebook or hotmail compose mail receiver list auto completer control.

    It would be great if you provide such a solution using autocompleter.js
  • reply
    Avatar
    randyjensen 13 Points
    said 1 year ago (1 Point)
    Has anyone been able to get this script working with an XML file? I've been trying anything possible for the last couple weeks to no avail.

    Even a little hint in the right direction would be much appreciated...
  • reply
    Avatar
    Shaxx
    said 1 year ago (1 Point)
    Why if you type word: alcal
    result is somthink like this :
    alcal�
    alcalae�a
    alcalae�as
    alcalae�os
    ..
  • reply
    Avatar
    Jason
    said 1 year ago (1 Point)
    I'm using this with the Autocompleter.Request implementation, but I cannot get it to work properly with 'fxOptions: null' set. It only selects if I use the arrow keys, not if I click.

    I'll try to set up a demo when I have time, but it's a little tricky right now.
  • reply
    Avatar
    iE
    said 1 year ago (1 Point)
    It does not work work content_type = application/xmtml+xml
  • reply
    Avatar
    bill
    said 1 year ago (1 Point)
    while(1)
    {
    echo 'thnks';
    }
  • reply
    Avatar
    CroNiX
    said 1 year ago (1 Point)
    Does anyone know if this works with mootools 1.2.1? I tried (yes core and more are loaded) and get "tokens.each is not a function" in Autocompleter.js line 291.
  • reply
    Avatar
    Alan
    replied 1 year ago (1 Point)
    I have the same issue. Anybody has a solution?
  • reply
    Avatar
    CroNiX
    replied 1 year ago (1 Point)
    My error was coming from my json being returned. I was doing:
    $results=array("key1"=>$somevalue, "key2"=>$somevalue2);
    return json_encode($results);

    The correct json was:
    $results=array($somevalue, $somevalue2);
    It cant be in key/pairs.
  • reply
    Avatar
    Alan
    replied 1 year ago (1 Point)
    Thanks, that solved the problem.
    However, I need to manage a complete json object, not a simple array. I need to get 2 values (id and string) instead of getting the string only.

    Is there a way to do that?

    Thanks
  • reply
    Avatar
    CroNiX
    replied 1 year ago (1 Point)
    I was in the same boat. What I ended up doing was returning my data like: "name [id]" with ID in brackets, then on the php side, once the form was sent with the "name [id]" I used preg_match to grab the contents of the brackets (the id) and all is good. Not the way I want to do it as it looks ugly. I tried using the "injectChoice" option to create options for a select box. That would have been nice because then it could be <option value="id">string</option>. I got it to create the options but couldn't get it to inject them into the <select> for some reason so I gave up. The select box would have also been nice because it has a scrollbar. I could really use it because I am searching a database of over 2 million names and there are a LOT of names very similar. Im close, but no cigar unfortunately.</select>
  • reply
    Avatar
    digitarald Site Owner
    replied 1 year ago (1 Point)
    I'll add a demo for that case this month. Can you post/mail your
    solution, I'd need to know the options you are using.
Comments 21 – 40 of 261:

Post your comment

Please use the support forums for discussing the project, asking questions or posting bug-fixes!


Internet Consultant & Contractor

I'm available to combine forces with you and your team to find the most simple, elegant and convenient web solutions . I await your call.

If you just like my work and want to say Thank You, donate via PayPal or Amazon Wish List.

Developer Resources & Tools