关于搜索下拉框问题~!!!!我刚看了一下类似 www.bwsyq.com 还有其它的搜索引擎在搜索的时候还有搜索下拉智能提示比如输入 性 下面还出来
性交
性爱
性交易
性能力类似的还有很多,不知道是怎么个实现原理?
没有的词,搜一次就记住了,难道就是传说中的云输入法?这些都是怎么实现的呢?请大家给予协助,希望有代码和详细说明!分不够再加!先谢谢了!
性交
性爱
性交易
性能力类似的还有很多,不知道是怎么个实现原理?
没有的词,搜一次就记住了,难道就是传说中的云输入法?这些都是怎么实现的呢?请大家给予协助,希望有代码和详细说明!分不够再加!先谢谢了!
这个用ajax 可以实现
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>
<title></title>
<style type="text/css">
*{
margin:0px;padding:0px;font-size:12px;
}
input{
width:100px;height:20px;border:1px solid #ccc;
} </style>
<script language="javascript">
var mails= ["[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]"];
function tips(id){
var info = document.getElementById('eId');
if(info.value != null && info.value.length != 0){
var tempValue
if(info.value.lastIndexOf(";") != -1){
tempValue = info.value.substr(info.value.lastIndexOf(";")+1);
}else {
tempValue = info.value;
}
var showMsg = "";
for(var i = 0 ;i < mails.length && tempValue !="" ; i ++){
if(mails[i].indexOf(tempValue) == 0){
showMsg += "<label type='text'style='cursor:hand' readonly='true' onclick='setAreaValue(this.value)' value='"+mails[i]+"'>"+mails[i]+"</label><br>";
}
}
var t = info.offsetTop + event.srcElement.createTextRange().text.length;
var l = info.offsetLeft + event.srcElement.createTextRange().text.length;
var tips = document.getElementById("tips");
tips.style.left = l + 10;
tips.style.top = t ;
if(showMsg == ""){
tips.style.display = "none";
}else {
tips.style.display = "";
tips.innerHTML = showMsg;
}
}
}
var infoValue ="";
function setAreaValue(value){
infoValue += value + ";";
document.getElementById('eId').value = infoValue;
document.getElementById('areaId').value += value+";";
}function outtips(){
document.getElementById("tips").style.display = 'none';
}
</script> </head> <body>
<div id="tips" style="position:absolute;border:1px solid #ccc;padding:0px 3px;color:#f00;display:none;height:20px;line-height:20px;background:#fcfcfc" onmouseup="outtips()"></div> email:<input type="text" id="eId" style="width:500px" onkeyup="tips('eId')" onfocus="tips('eId')" /> <br /><br /><br /><br /><br /><br /><br /><br /><br /><textarea rows="5" cols="50" id="areaId"></textarea>
</body>
</html>
再在你输入框的下面用一个DIV,来显示数据
大体思路就是这样
up 4楼!