/*封装成比较完整的table类,重用率过低了,花点时间包装了一下,对JS又多了层认识*/
function tableCreater(tablename)
{
var t=this.newtable = document.createElement("table");
t.id=tablename;
t.style.width="100%"
this.newtable=t;
this.rows=new Array();
}
tableCreater.prototype.createBody=function(tbname)
{
this.tbody=document.createElement("tbody");
this.tbody.id=tbname;
this.newtable.appendChild(this.tbody);
}
tableCreater.prototype.addTextRow=function(textarr,style)
{
var tr1=document.createElement("tr");
tr1.className=style;
for(var j=0;j<textarr.length;j++)
{
var tdarr=tableCreater.prototype.addCell(textarr[j]);
tr1.appendChild(tdarr);
}
this.tbody.appendChild(tr1);
}
tableCreater.prototype.addCell=function(text)
{
var td1=document.createElement("td");
var ttext=document.createTextNode(text);
td1.appendChild(ttext);
return td1;
}
tableCreater.prototype.addBoxRows=function(texts,names,style)
{
var tr=document.createElement("tr");
tr.className=style;
for(var j=0;j<names.length;j++)
{
var text_1=tableCreater.prototype.addCell(texts[j]);
var tdarr=tableCreater.prototype.makeBox(names[j]);
tr.appendChild(text_1);
tr.appendChild(tdarr);
}
this.tbody.appendChild(tr);
}
tableCreater.prototype.makeBox=function(name)
{
var td=document.createElement("td");
var box=document.createElement("input");
box.id=name;
box.setAttribute("type","text");
td.appendChild(box);
return td;
}
tableCreater.prototype.gettable=function()
{
return this.newtable;
}