日期:2014-05-16 浏览次数:20329 次
核心JAVASCRIPT代码:
<script type="text/javascript"> /** * 动态改变行 * @param {Object} iInx */ function doOnchange(iInx){ var iRows = iInx ? iInx : 0; removeRow('tbl'); for(var v=0;v<iRows;v++){ instRow('tbl'); } } /** * 插入行 * @param {Object} tblId ?*/ function instRow(tblId){ var row = document.getElementById(tblId).all.tags("tbody")[0].insertRow(); var rowCount = document.getElementById(tblId).rows.length; var countCell = document.getElementById(tblId).rows.item(0).cells.length; for (var i = 0; i < countCell; i++) { var cell = row.insertCell(i); cell.innerHTML = "new-" + (rowCount) + "/" + (i + 1) + "-col"; cell.id = (rowCount) + "-" + (i + 1); } } /** * 删除行 * @param {Object} tblId */ function removeRow(tblId){ var rows = document.getElementById(tblId).all.tags("tbody")[0].rows.length; for (var i = rows-1; i >=0; i--) { document.getElementById(tblId).all.tags("tbody")[0].deleteRow(); } } </script>?