运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,暗/亮
前往 Spaces
<!DOCTYPE html> <html> <style> th,td { padding: 5px; } </style> <body> <h2>The XMLHttpRequest Object</h2> <form action=""> <select name="customers" onchange="showCustomer(this.value)"> <option value="">Select a customer:</option> <option value="ALFKI">Alfreds Futterkiste</option> <option value="NORTS ">North/South</option> <option value="WOLZA">Wolski Zajazd</option> </select> </form> <br> <div id="txtHint">Customer info will be listed here...</div> <script> function showCustomer(str) { if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } const xhttp = new XMLHttpRequest(); xhttp.onload = function() { document.getElementById("txtHint").innerHTML = this.responseText; } xhttp.open("GET", "getcustomer.php?q="+str); xhttp.send(); } </script> </body> </html>