文本框问题 在一个文本快 输入多个值 这些值是数据库读出来的 且文本框带自动补全 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 既然你的问题问的那么浅显易懂。。那我也回答的浅显易懂好了AJAX 可以上传图片的啊!~ 你先把你的图片存在csdn的相册里面,然后在把图片放在这里就可以了!~如果是你说的那样的话!~ 直接每次做追加 可行不!~ 数据库读取到一条数据后 把数据现在text显示出来 在读取 就获取text的值 在追加上数据库读取的值!~~~~~~~~ 感觉有点想的浅显了...... 使用jqueryui的autocomplete试试http://jqueryui.com/demos/autocomplete/ 自动补全 是说 百度搜索框效果吗?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head> <title></title> <style type ="text/css"> html,body{width:100%;height:100%} ul{padding:0px;margin:0px;list-style:none;} li{cursor:pointer;padding:0px 5px; line-height:25px;height:25px;} </style></head><body> <p> <input type='text' id='txtInput' onkeyup='getSearchKeys()'/> <div id='divShow' style="position:absolute; z-index:9999; width:200px; height:auto; display:none;border:1px solid #ddd"> <ul> <li>aaa</li> </ul> </div> </p></body><script type="text/javascript">var keys=['ada','sdfsd','bbb','sfga','dfhgfh','235s','dfew','ghjk','hjkghjk','fgjgfjf','fghjgfj','2345f','fthtr','sfgerw','tyerth','vnmu','wertewr','wert','asdfaf','zxcvd','gkju','dvfgdh','2354af','adsf','erterter','fghdfg','xvdfg','kjhu','qweasdas','xzce','werwre','zzczc','rtewtrew']; // 搜索值,可以用Ajax从数据库获取var txtInput ;var divShow ;window.onload=function(){ txtInput =document.getElementById("txtInput"); divShow = document.getElementById("divShow"); var p =getAbsPoint(txtInput); divShow.style.left = p.x +'px'; divShow.style.top = p.y + txtInput.offsetHeight + 'px'; txtInput.onclick = divShow.onclick=function(e) { e = e||event; var t = e.target||e.srcElement if(t.tagName.toLowerCase()=='li') { txtInput.value = t.innerHTML; divShow.style.display = "none"; return; } if(e && e.stopPropagation){ //W3C取消冒泡事件 e.stopPropagation(); }else{ //IE取消冒泡事件 window.event.cancelBubble = true; } }; document.body.onclick=function(e) { divShow.style.display = "none"; };};function getSearchKeys(){ var s= txtInput.value; if(s=='') { divShow.style.display = "none"; return; } var arr=['<ul>']; for(var i=0;i<keys.length;i++) { if(keys[i].indexOf(s)>=0){ arr.push('<li>'+keys[i]+'</li>'); } } if(arr.length>1){ arr.push('</ul>'); divShow.innerHTML = arr.join(''); divShow.style.display = "block"; }else{ divShow.style.display = "none"; }}function getAbsPoint(e){ var x = e.offsetLeft; var y = e.offsetTop; while(e = e.offsetParent) { x += e.offsetLeft; y += e.offsetTop; } return {"x": x, "y": y};}</script></html> 这个JS脚本怎么理解。 JavaScript的模块化加载问题 xml解析问题 JSP中,为什么调用String 的 lastIndexOf 函数错误? 救命啊!!extjs中布局---如何将html属性中的图片位于items中元素的上方 急啊救命啊 怎么用 java script 算出某年的某个月的某个星期的星期几 是几号 我是实在没有分了 求帮忙了 (求助!!)div重复问题 关于更改编辑器插入字体颜色的问题 如何获得<img>的src的值? 页面元素隐藏的问题 Event事件问题 .net中定时刷新页面,但文本框中内容不变
AJAX
如果是你说的那样的话!~ 直接每次做追加 可行不!~ 数据库读取到一条数据后 把数据现在text显示出来 在读取 就获取text的值 在追加上数据库读取的值!~~~~~~~~
感觉有点想的浅显了......
http://jqueryui.com/demos/autocomplete/
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<style type ="text/css">
html,body{width:100%;height:100%}
ul{padding:0px;margin:0px;list-style:none;}
li{cursor:pointer;padding:0px 5px; line-height:25px;height:25px;}
</style>
</head>
<body>
<p>
<input type='text' id='txtInput' onkeyup='getSearchKeys()'/>
<div id='divShow' style="position:absolute; z-index:9999; width:200px; height:auto; display:none;border:1px solid #ddd">
<ul>
<li>aaa</li>
</ul>
</div>
</p>
</body>
<script type="text/javascript">
var keys=['ada','sdfsd','bbb','sfga','dfhgfh','235s','dfew','ghjk','hjkghjk','fgjgfjf','fghjgfj','2345f','fthtr','sfgerw','tyerth','vnmu','wertewr','wert','asdfaf','zxcvd','gkju','dvfgdh','2354af','adsf','erterter','fghdfg','xvdfg','kjhu','qweasdas','xzce','werwre','zzczc','rtewtrew']; // 搜索值,可以用Ajax从数据库获取
var txtInput ;
var divShow ;
window.onload=function()
{
txtInput =document.getElementById("txtInput");
divShow = document.getElementById("divShow");
var p =getAbsPoint(txtInput);
divShow.style.left = p.x +'px';
divShow.style.top = p.y + txtInput.offsetHeight + 'px';
txtInput.onclick = divShow.onclick=function(e)
{
e = e||event;
var t = e.target||e.srcElement if(t.tagName.toLowerCase()=='li')
{
txtInput.value = t.innerHTML;
divShow.style.display = "none";
return;
}
if(e && e.stopPropagation){
//W3C取消冒泡事件
e.stopPropagation();
}else{
//IE取消冒泡事件
window.event.cancelBubble = true;
}
};
document.body.onclick=function(e)
{
divShow.style.display = "none";
};
};
function getSearchKeys()
{
var s= txtInput.value;
if(s=='')
{
divShow.style.display = "none";
return;
}
var arr=['<ul>'];
for(var i=0;i<keys.length;i++)
{
if(keys[i].indexOf(s)>=0){
arr.push('<li>'+keys[i]+'</li>');
}
}
if(arr.length>1){
arr.push('</ul>');
divShow.innerHTML = arr.join('');
divShow.style.display = "block";
}else{
divShow.style.display = "none";
}
}function getAbsPoint(e)
{
var x = e.offsetLeft;
var y = e.offsetTop;
while(e = e.offsetParent)
{
x += e.offsetLeft;
y += e.offsetTop;
}
return {"x": x, "y": y};
}
</script>
</html>