String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
">
ajax.mouseOver{
background: #708090;
color: #FFFAFA;
}
.mouseOut{
background: #FFFAFA;
color: #000000;
}
var xmlHttp;
function getMoreContents(){
var content=document.getElementById("keyword");
if(content.value==""){
clearContent();
return;
}
xmlHttp=createXMLHttp();
var url="search?keyword="+escape(content.value);
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=callback;
xmlHttp.send(null);
}
//创建xmlHttp对象
function createXMLHttp(){
var xmlHttp;
if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
if(!xmlHttp){
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
}
return xmlHttp;
}
//回调函数
function callback(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
var result=xmlHttp.responseText;
var json=eval("("+result+")");
setContent(json);
}
}
}
//设置关联数据的展示
function setContent(contents){
clearContent();
setLocation();
var size=contents.length;
for(var i=0;i
var nextNode=contents[i];
var tr=document.createElement("tr");
var td=document.createElement("td");
td.setAttribute("border", "0");
td.setAttribute("bgcolor", "#FFFAFA");
td.setAttribute("id",i);
td.οnmοuseοver=function(){
this.className='mouseOver';
};
td.οnmοuseοut=function(){
this.className='mouseOut';
};
td.οnclick=function(){//点击获取td的值
document.getElementById("keyword").value=this.innerHTML;
clearContent();
};
var text=document.createTextNode(nextNode);
td.appendChild(text);
tr.appendChild(td);
document.getElementById("content_table_body").appendChild(tr);
}
}
//清空之前的数据
function clearContent(){
var contTableBody=document.getElementById("content_table_body");
var size=contTableBody.childNodes.length;
for(var i=size-1;i>=0;i--){
contTableBody.removeChild(contTableBody.childNodes[i]);
}
document.getElementById("popDiv").style.border="none";
}
//失去焦点时
function keywordBlur(){
setTimeout("clearContent()",1000);//停一秒再清空,不然选择无效
}
//设置数据展示样式
function setLocation(){
var content=document.getElementById("keyword");
var width=content.offsetWidth;
var left=content["offsetLeft"];
var top=content["offsetTop"]+content.offsetHeight;
var popDiv=document.getElementById("popDiv");
popDiv.style.border="black 1px solid";
//popDive.style.left=left+"px";
//popDiv.style.top=top+"px";
popDiv.style.width=width+"px";
document.getElementById("content_table").style.width=width+"px";
}