js添加table

IE 和FF浏览器都可以用

1.向comp_table中添加行和列
function addTableRow(){
var objTable = document.getElementById('comp_table');
var row = objTable.insertRow(-1);
var cell_1 = row.insertCell(-1);				
cell_1.innerHTML = '<input type=\"text\" name=\"cName\"> ';
}

2. 添加table,行 和列
function addTable() {
	var divObj = document.getElementById('itemTable');
	var table=document.createElement("table");
	var row1 = table.insertRow(-1);
	var row2 = table.insertRow(-1);
	var row3 = table.insertRow(-1);
	
	var r1_cell1 = row1.insertCell(-1);
	var r1_cell2 = row1.insertCell(-1);
	var r1_cell3 = row1.insertCell(-1);
	var r1_cell4 = row1.insertCell(-1);
	r1_cell1.innerHTML = '<liferay-ui:message key="erp.quaerePrice.commodityName" />';
	r1_cell2.innerHTML = '<input type=\"text\" name=\"commodityName\" size=\"30\"> ';
	r1_cell3.innerHTML = '<liferay-ui:message key="erp.quaerePrice.commodityType"/> ';
	r1_cell4.innerHTML = '<select name=\"commodityType\"><option><liferay-ui:message key="erp.select.option.choose"/></option><c:forEach var="item" items="${itemList }"><option value="${item.itemtype }">${item.itemtypename }</option></c:forEach></select>';

你可能感兴趣的:(浏览器,IE)