andymjia

CODIGO EJEMPLO

Sep 4th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <!DOCTYPE html><html><head><title>Cursos aprende a programar</title><meta charset="utf-8">
  2. <script>
  3. function mostrarSugerencia(str) {
  4. var xmlhttp;
  5. if (str.length==0) { document.getElementById("txtSugerencia").innerHTML=""; return; }
  6. xmlhttp=new XMLHttpRequest();
  7. xmlhttp.onreadystatechange = function() {
  8. if (xmlhttp.readyState==4 && xmlhttp.status==200) {
  9. document.getElementById("txtSugerencia").innerHTML=xmlhttp.responseText;
  10. }
  11. }
  12. xmlhttp.open("GET","listadoDatos.php?q="+str,true);
  13. xmlhttp.send();
  14. }
  15. </script></head>
  16. <body><h3>Empieza a escribir un nombre en la casilla para obtener una sugerencia:</h3>
  17. <form action="">
  18. Nombre: <input type="text" id="txt1" onkeyup="mostrarSugerencia(this.value)" />
  19. </form>
  20. <p>Sugerencias: <span id="txtSugerencia"></span></p>
  21. </body></html>
Advertisement
Add Comment
Please, Sign In to add comment