Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h2>The XMLHttpRequest Object</h2> <h3>Start typing a name in the input field below:</h3> <p>Suggestions: <span id="txtHint"></span></p> <p>First name: <input type="text" id="txt1" onkeyup="showHint(this.value)"></p> <script> function showHint(str) { if (str.length == 0) { document.getElementById("txtHint").innerHTML = ""; return; } const xhttp = new XMLHttpRequest(); xhttp.onload = function() { document.getElementById("txtHint").innerHTML = this.responseText; } xhttp.open("GET", "gethint.asp?q="+str); xhttp.send(); } </script> </body> </html>