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 onclick=\"document.getElementById('word').value=this.innerHTML;document.getElementById('showmenu').style.display='none';\" onmouseover=\"this.style.backgroundColor='#666666'\" onmouseout=\"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>