www.gusucode.com > JSP ExtJS图书管理系统源码程序 > JSP ExtJS图书管理系统/在实战中成长:JSP开发之路图书项目资料/WebContent/book/js/viewHistory.js
document.write("<script language='javascript' src='loadImages.js'></script>"); document.write("<script language='javascript' src='displayImage.js'></script>"); var url="/book/include/viewhistory_xml.jsp"; function loadViewHistory(table){ var xmlHttp=createHttpRequest(); var currId = "mydiv_1"; xmlHttp.open("GET",url+"?op=read", true); xmlHttp.onreadystatechange=function(){ if(xmlHttp.readyState == 4){ if(xmlHttp.status == 200){ var responseXML=xmlHttp.responseXML; var commodity=responseXML.getElementsByTagName("commodity"); if(commodity!=undefined&&commodity.length>0){ for(var i=0;i<commodity.length;i++){ var owncode=commodity[i].getElementsByTagName("owncode")[0].firstChild.nodeValue; var name=commodity[i].getElementsByTagName("name")[0].firstChild.nodeValue; var author=commodity[i].getElementsByTagName("author")[0].firstChild.nodeValue; var productDate=commodity[i].getElementsByTagName("productDate")[0].firstChild.nodeValue; var manufacturer=commodity[i].getElementsByTagName("manufacturer")[0].firstChild.nodeValue; var picutrePath=commodity[i].getElementsByTagName("picutrePath")[0].firstChild.nodeValue; var tr=document.createElement("tr"); var td=document.createElement("td"); td.setAttribute("style","padding:2px 0"); var div1=document.createElement("div"); var div2=document.createElement("div"); div2.id="mydiv_"+i+"_d"; div2.style.display="none"; //设置div1的属性 div1是原来显示的数据 div1.id="mydiv_"+i; div1.style.borderBottom="1px dashed #D1C9B1"; div1.style.padding="3px"; div1.onmouseover=function(){ var rowIndex=this.parentNode.parentNode.rowIndex; if(currId!=this.id){ document.getElementById("mydiv_"+rowIndex+"_d").style.display="block"; this.style.display="none"; document.getElementById(currId+"_d").style.display="none"; document.getElementById(currId).style.display="block"; } currId=this.id; }; div1.appendChild(document.createTextNode(substring(name,14))); div1.setAttribute("title",name); //设置div2的属性 动态创建一个table放入div2中 var info="<table width='100%' style='border-bottom:1px dashed #D1C9B1; padding:3px;'><tr valign='top'><td rowspan='4' width='30%' align='center'>"+ "<a href='/content/1-"+owncode+".htm' target='_blank' title='"+name+"'><img alt='"+name+"' src='"+picutrePath+"'"+ " width='50' height='80' border='0' /></a>"+ "</td><td align='left'><a href='/content/1-"+owncode+".htm' target='_blank' title='"+name+"'>"+ "<strong>"+substring(name,6)+"</strong></a>"+ "</td></tr><tr><td>作者:"+substring(author,6)+"</td></tr><tr><td>出版社:"+substring(manufacturer,4)+"</td></tr><tr><td>出版日期:"+productDate+"</td></tr></table>"; div2.innerHTML=info; td.appendChild(div1); td.appendChild(div2); tr.appendChild(td); table.appendChild(tr); } }else{ var tr=document.createElement("tr"); var td=document.createElement("td"); td.appendChild(document.createTextNode("无记录")); tr.appendChild(td); table.appendChild(tr); } } } }; xmlHttp.send(null); } function substring(str,length){ if(str.length<=length) return str; else return str.substring(0,length)+"..."; } function addViewHistory(owncode){ var xmlHttp=createHttpRequest(); xmlHttp.open("GET",url+"?op=add&owncode="+owncode, true); xmlHttp.send(null); }