WZH75171992

View Post

一个按下键盘触发事件的例子

<html>
<head>
<script type="text/javascript">
function showHint(str)
{
var xmlhttp;
if (str.length==0)
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","/ajax/gethint.asp?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>

<h3>请在下面的输入框中键入字母(A - Z):</h3>
<form action="">
姓氏:<input type="text" id="txt1" onkeyup="showHint(this.value)" />
</form>
<p>建议:<span id="txtHint"></span></p>

</body>
</html>

分类:

技术点:

相关文章:

  • 2022-01-10
  • 2021-11-16
  • 2022-12-23
  • 2021-07-18
  • 2022-12-23
  • 2021-11-27
  • 2021-06-07
  • 2021-11-29
猜你喜欢
  • 2021-12-14
  • 2021-11-23
  • 2021-12-07
  • 2021-11-29
  • 2021-11-27
  • 2022-02-09
  • 2021-12-12
相关资源
相似解决方案