AJAX智能
完成AJAX的智能提示.
<script language="javascript" src="../inc/ajax.js"></script>
<script language="javascript" type="text/javascript">
function checkword()
{
?var flag;
?var wordvalue=(document.getElementById("word").value.toLowerCase()).replace(/(^\s*)|(\s*$)/g,? "");?
?var xmlhttp;
?xmlhttp=new AJAXRequest;
?xmlhttp.method="get";
?xmlhttp.url="../inc/GetCusName.asp?wordvalue="+ wordvalue +"";
?//alert(xmlhttp.url);
?xmlhttp.callback=function(xmlhttp){
??flag=xmlhttp.responseText;
??//alert(flag);
?if(flag!=0)
?{?
??? var alltxtpp=flag.toLowerCase();
??? var alltxt_xiang=flag.split("|");
??? var alltxt_xiang1=alltxtpp.split("|");
??? var inhtml="<ul>"
??? var isyou=0;
??? for (i=0;i<alltxt_xiang1.length;i++)
??? {
???? //if (alltxt_xiang1[i].substr(0,wordvalue.length)==wordvalue)
??? // if(alltxt_xiang1[i].indexOf(wordvalue)>-1)
??? // {
????? inhtml=inhtml+"<li οnclick=\"document.getElementById('word').value=this.innerHTML;document.getElementById('showmenu').style.display='none';\" οnmοuseοver=\"this.style.backgroundColor='#666666'\" οnmοuseοut=\"this.style.backgroundColor=''\">"+alltxt_xiang[i]+"</li>";
????? isyou=1;
???? //}
??? }
??? inhtml=inhtml+"</ul>";
???
?? // alert(inhtml);
??? if (isyou==1)
??? {
???? document.getElementById("showmenu").innerHTML=inhtml;
???? document.getElementById("showmenu").style.display="";
??? }
??? else
??? {
???? document.getElementById("showmenu").innerHTML="";
???? document.getElementById("showmenu").style.display="none";
??? }
??? if (wordvalue=="")
??? {
???? document.getElementById("showmenu").innerHTML="";
???? document.getElementById("showmenu").style.display="none";
??? }
??
?}else
??{document.getElementById("showmenu").style.display="none"}?
??
??
?}
??xmlhttp.send(null);
?
}
</script>
?
<input name="word" size="20" id="word" type="text" onKeyUp="checkword()">
</label>
<div style="position: absolute; width: 200px; height: 100px; z-index: 1; left: 10px; top: 40px;border:1px solid #666666;display:none;" id="showmenu"></div>
轉載于:https://www.cnblogs.com/jason_yjau/archive/2008/10/13/1310253.html
總結
- 上一篇: “HTTP 500 - 内部服务器错误”
- 下一篇: Linux 文本界面转到图形界面