var myinput = $('#edit-name1').attr('autocomplete', 'OFF')[0];
var db = new Drupal.ACDB('http://localhost/myproject/?q=my/autocomplete');
var x = new Drupal.jsAC(myinput, db);
x.found = function (matches) {
// If no value in the textfield, do not show the popup.
if (!this.input.value.length) {
return false;
}
// Prepare matches
var ul = document.createElement('ul');
var ac = this;
for (key in matches) {
var li = document.createElement('li');
$(li)
.html('<div>'+ matches[key]['display'] +'</div>')
.mousedown(function () { ac.select(this); })
.mouseover(function () { ac.highlight(this); })
.mouseout(function () { ac.unhighlight(this); });
li.autocompleteValue = key;
li.info = matches[key]['info'];
$(ul).append(li);
}
// Show popup with matches, if any
if (this.popup) {
if (ul.childNodes.length > 0) {
$(this.popup).empty().append(ul).show();
}
else {
$(this.popup).css({visibility: 'hidden'});
this.hidePopup();
}
}
}
x.select = function (node) {
this.input.value = node.autocompleteValue;
this.info = node.info;
var newdiv = $("<div></div>").addClass("messages status")
.html("OK.");
$("input#edit-email1").parent().fadeOut("slow").after(newdiv);
$("#edit-uid1").val(this.info['uid']);
}