Ajaxian Featured Tutorial: AutoCompleter 101
Written by on September 24th, 2007 in Ajax News.
Jamie Mcconnell has taken the age old classic Ajax autocompleter, and has created a simple tutorial using jQuery and PHP. Jamie takes time to explain the “why” as much as the “how”:
JAVASCRIPT:
-
-
<script src=”jquery-1.2.1.pack.js” type=”text/javascript”></script><script type=”text/javascript”>
-
-
function lookup(inputString) {
-
if(inputString.length == 0) {
-
// Hide the suggestion box.
-
$(‘#suggestions’).hide();
-
} else {
-
$.post(”rpc.php”, {queryString: “”+inputString+”"}, function(data){
-
if(data.length>0) {
-
$(‘#suggestions’).show();
-
$(‘#autoSuggestionsList’).html(data);
-
}
-
});
-
}
-
} // lookup
-
-
function fill(thisValue) {
-
$(‘#inputString’).val(thisValue);
-
$(‘#suggestions’).hide();
-
}
-
</script>
-
You can see it in action and download the source.
Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/160586843/ajaxian-featured-tutorial-autocompleter-101
