<div class="codetitle"> <span><a style="CURSOR: pointer" data="95031" class="copybut" id="copybut95031" onclick="doCopy('code95031')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code95031"> <br><br><br><script language="javascript"> <BR> //窗口表格增加一行<BR> function addNewRow(){<BR> var tabObj=document.getElementById("myTab");//获取添加数据的表格<BR> var rowsNum = tabObj.rows.length; //获取当前行数<BR> var colsNum=tabObj.rows[rowsNum-1].cells.length;//获取行的列数<BR> var myNewRow = tabObj.insertRow(rowsNum);//插入新行<BR> var newTdObj1=myNewRow.insertCell(0);<BR> newTdObj1.innerHTML="<input type='checkbox' name='chkArr' id='chkArr'"+rowsNum+" style='width:20px' />";<BR> var newTdObj2=myNewRow.insertCell(1);<BR> newTdObj2.innerHTML="<input type='text' name='nodecode' id='nodecode'"+rowsNum+" style='width:40px' value='"+rowsNum+"'/>";<BR> var newTdObj3=myNewRow.insertCell(2);<BR> newTdObj3.innerHTML="<input type='text' name='nodename' id='nodename'"+rowsNum+" style='width:120px' />";<BR> var newTdObj4=myNewRow.insertCell(3);<BR> newTdObj4.innerHTML="<input type='text' name='nodeper' id='nodeper'"+rowsNum+" style='width:60px' />";<BR> }<BR>//窗口表格删除一行<BR> function removeRow(){<BR> var chkObj=document.getElementsByName("chkArr");<BR> var tabObj=document.getElementById("myTab");<BR> for(var k=0;k<chkObj.length;k++){<BR> if(chkObj[k].checked){<BR> tabObj.deleteRow(k+1);<BR> k=-1;<BR> }<BR> }<BR> }<BR></script><br><br><br><input type="button" name="xx" onclick="addNewRow();" value="增加一行"><br><input type="button" name="yy" onclick="removeRow();" value="删除一行"><br><table width="600px" border="1" cellpadding="0" cellspacing="0" id="myTab"> <br> <tr> <br> <td width="40px" class="top-bt liebiao-c" align="center">操作</td> <br> <td width="40px" class="top-bt liebiao-c" align="center">序号</td> <br> <td class="top-bt liebiao-c" align="center">节点名称</td> <br> <td width="80px" class="top-bt liebiao-c" align="center">节点比例</td> <br> </tr> <br> </table> <br><br><br> </div>