Aquí va "autocomplete"
Código PHP:
function autocomplete (thevalue, e){
theObject = document.getElementById("autocompletediv");
theObject.style.visibility = "visible";
theObject.style.width = "152px";
var posx = 0;
var posy = 0;
posx = (findPosX (document.getElementById("yourname")) + 1);
posy = (findPosY (document.getElementById("yourname")) + 23);
theObject.style.left = posx + "px";
theObject.style.top = posy + "px";
var theextrachar = e.which;
if (theextrachar == undefined){
theextrachar = e.keyCode;
}
//The location we are loading the page into.
var objID = "autocompletediv";
//Take into account the backspace.
if (theextrachar == 8){
if (thevalue.length == 1){
var serverPage = "html/index/autocomp.php";
} else {
var serverPage = "html/index/autocomp.php" + "?sstring=" + thevalue.substr (0, (thevalue.length -1));
}
} else {
var serverPage = "html/index/autocomp.php" + "?sstring=" + thevalue + String.fromCharCode (theextrachar);
}
var obj = document.getElementById(objID);
xmlhttp.open("GET", serverPage);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
obj.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}