PHP와 작동 메커니즘 동일
https://homzzang.com/b/js-84
b.asp
<p>제시어: <span id="txtHint"></span></p>
<p>입력: <input type="text" id="txt1" onkeyup="hz(this.value)"></p>
<script>
function hz(str) {
var xhttp;
if (str.length == 0) {
document.getElementById("txtHint").innerHTML = "";
return;
}
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("txtHint").innerHTML = this.responseText;
}
};
xhttp.open("GET", "a.asp?q="+str, true);
xhttp.send();
}
</script>
a.asp
<%
response.expires=-1
dim a(2 )
a(1)="홈짱닷컴"
a(2 )="Homzzang.com"
q=ucase(request.querystring("q"))
if len(q)>0 then
hint=""
for i=1 to 2
if q=ucase(mid(a(i),1,len(q))) then
if hint="" then
hint=a(i)
else
hint=hint & " , " & a(i)
end if
end if
next
end if
if hint="" then
response.write("제시어 없음")
else
response.write(hint)
end if
%>
주소 복사
랜덤 이동