El código completo es este...
Código Javascript
:
Ver original<script language = "javascript">
function createRequestObject(){
var peticion;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
peticion = new ActiveXObject("Microsoft.XMLHTTP");
}else{
peticion = new XMLHttpRequest();
}
return peticion;
}
var http = new Array();
function ObtDatos(url){
var act = new Date();
http[act] = createRequestObject();
http[act].open('get', url);
http[act].onreadystatechange = function() {
if (http[act].readyState == 4) {
if (http[act].status == 200 || http[act].status == 304) {
var texto
texto = http[act].responseText
var ListaDesplegable = document.getElementById("ListaDesplegable");
ListaDesplegable.innerHTML = texto;
}
}
}
http[act].send(null);
}
function compUsuario(Tecla) {
Tecla = (Tecla) ? Tecla: window.event;
input = (Tecla.target) ? Tecla.target :
Tecla.srcElement;
if (Tecla.type == "keyup") {
if (input.value) {
ObtDatos("./select_users.php?q=" + input.value);
}
}
}
var http = new Array();
function validarUser(url){
var act = new Date();
http[act] = createRequestObject();
http[act].open('get', url);
http[act].onreadystatechange = function() {
if (http[act].readyState == 4) {
if (http[act].status == 200 || http[act].status == 304) {
var texto
texto = http[act].responseText;
document.write(http[act].responseText);
if(http[act].responseText=="no"){
var ErrorDiv = document.getElementById("ErrorDiv");
ErrorDiv.innerHTML = "No existe este user";
}else{
var ErrorDiv = document.getElementById("ErrorDiv");
ErrorDiv.innerHTML = "Ok";
document.UserSearch.submit();
}
}
}
}
http[act].send(null);
}
function marcarusuario(usuario){
document.UserSearch.UserSearchText.value=usuario;
var ListaDesplegable = document.getElementById("ListaDesplegable");
ListaDesplegable.innerHTML = "";
}
</script>