主要是點擊增加按鈕,實現添加一行input單元格,並可以刪除
麻煩各位了,謝謝,http://ask.csdn.net/my#
給你一個純js的樣例,希望對你的基礎能力有幫助
function DeleteRouteTable(divId, riF, nameF, msgF){
this.riField = riF;
this.nameField = nameF;
this.msgField = msgF;
var div = document.getElementById(divId);
this.table = document.createElement("TABLE");
div.appendChild(this.table);
this.table.width = "100%";
this.table.cellSpacing = 0;
this.table.border = 1;
this.tbody = document.createElement("TBODY");
this.table.appendChild(this.tbody);
this.arrayRI = new Array();
}
DeleteRouteTable.prototype.setValue = function(array){
while(this.table.rows.length>0){
this.table.deleteRow(0);
}
for(var i=0;i<array.length;i++){
var item = array[i];
this.arrayRI.push(item[this.riField]);
var tr = document.createElement("TR");
this.tbody.appendChild(tr);
var tdRi = this.createTD(item[this.riField], 100, 2, "black");
tr.appendChild(tdRi);
var tdName = this.createTD(item[this.nameField], 100, 2, "black");
tr.appendChild(tdName);
var tdMsg = this.createTD(item[this.msgField], -1, 2, "red");
tr.appendChild(tdMsg);
}
};
DeleteRouteTable.prototype.createTD = function(value, width, fontSize, fontColor){
var td = document.createElement("TD");
if(width!=-1){
td.width = width;
}
var font = document.createElement("FONT");
td.appendChild(font);
font.size = fontSize;
font.color = fontColor;
font.innerText = value;
return td;
};