我的代碼在窗體選擇選項html代碼中工作良好。 但表單輸入菜單沒有。 以下是我的代碼。在html中,我如何更改輸入html代碼的選擇選項菜單?
<script>
function showUser(str)
{
if (str=="")
{
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","getuser.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<select name="users" onchange="showUser(this.value)">
<option value="">Select a person:</option>
<option value="1">Peter Griffin</option>
<option value="2">Lois Griffin</option>
<option value="3">Glenn Quagmire</option>
<option value="4">Joseph Swanson</option>
</select>
</form>
<br>
<div id="txtHint"><b>Person info will be listed here.</b></div>
以上是好!但下面是我的代碼。爲什麼不工作? 輸入類型=「提交」也無法正常工作。 我該如何克服這個問題?
<script>
same as above...
</script>
</head>
<body>
<form>
<select name="users" onchange="showUser(this.value)">
## Here is wrong, input element.##
<input type="text" name="users" onkeyup="showUser(this.value)>
</select>
</form>
<br>
<div id="txtHint"><b>Person info will be listed here.</b></div>
什麼問題? 幫幫我!
什麼''裏面'
歡迎來到stackoverflow新的用戶。你應該接受答案,如果你認爲你在找什麼。 – ncm