今天建民老师又给了任务——要显示热词云topn的热词到表格里那么话不多说,开整
先是插入一条数据到表格的函数:
function dogo(tableid,data1,data2,data3){ var tab=document.getElementById(tableid); var x=tab.insertRow(0); var x1=x.insertCell(0); var x2=x.insertCell(1); var x3=x.insertCell(2); var x4=x.insertCell(3); x1.innerHTML="<span id=\""+data1+"\" onclick=\"totext('"+data1+"')\">"+data1+"</span>"; x3.innerHTML="<a href=\""+data2+"\" color=\"#FEB89F\"><i class='layui-icon layui-icon-download-circle' style='font-size: 25px; '></i> </i> </a>"; x2.innerHTML=data3; x4.innerHTML="<span onclick=\"pox('delete?id="+data1+"&ip="+tableid.substring(0,4)+"')\" color=\"red\"><i class='layui-icon layui-icon-fonts-del' style='font-size: 25px; '></a>"; }
之后调用循环函数循环插入全部数组
function changeable(){ var year=document.getElementById("year").value; var title=document.getElementById("title").value; var title1=document.getElementById("title1").value; var title2=document.getElementById("title2").value; var title3=document.getElementById("title3").value; var title4=document.getElementById("title4").value; var title5=document.getElementById("title5").value; var tab=document.getElementById("iccvtable"); for( var i=0;i<tab.rows.length;){ tab.deleteRow(0); } tab=document.getElementById("eccvtable"); for( var i=0;i<tab.rows.length;){ tab.deleteRow(0); } tab=document.getElementById("cvrptable"); for( var i=0;i<tab.rows.length;){ tab.deleteRow(0); } ic=0;ec=0;cv=0; for(var i = 0;i < iccv.length; i++){ if(srcs(iccv[i].title.toLowerCase())&&iccv[i].year.includes(year)){ dogo("iccvtable",iccv[i].title,iccv[i].links,iccv[i].year); ic++; } } for(var i = 0;i < eccv.length; i++){ if(srcs(eccv[i].title.toLowerCase())&&eccv[i].year.includes(year)){ dogo("eccvtable",eccv[i].title,eccv[i].links,eccv[i].year); ec++; } } for(var i = 0;i < cvrp.length; i++){ if(srcs(cvrp[i].title.toLowerCase())&&cvrp[i].year.includes(year)){ dogo("cvrptable",cvrp[i].title,cvrp[i].links,cvrp[i].year); cv++; } } }
最后可以得到如下效果: