js动态生成,删除一行td

xiaoxiao2021-02-28  56

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=" http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <SCRIPT LANGUAGE="JavaScript"> <!-- var rid=1; function creatTRTD(){ var thisid=rid;//当前id var mytable = document.getElementById("table1"); var myTR = mytable.insertRow(-1); var myjTD=myTR.insertCell(-1); myTR.id="row"+thisid; myjTD.id="step"+thisid; myjTD.innerHTML='步骤'+(thisid+1); var myjTD1= mytable.rows[thisid].insertCell(-1); myjTD1.innerHTML='浏览用户:<SELECT id="selGroup'+thisid+'"><option>选择用户组</option><option>所有用户组</option><option>用户组1</option></SELECT><SELECT id="selUser'+thisid+'"><option>选择用户</option><option>所有用户</option><option>用户1</option></SELECT>'; var myjTD2= mytable.rows[thisid].insertCell(-1); myjTD2.innerHTML='审批用户:<SELECT id="examGroup'+thisid+'"><option>选择用户组</option><option>所有用户组</option><option>用户组1</option></SELECT><SELECT id="examUser'+thisid+'"><option>选择用户</option><option>所有用户</option><option>用户1</option></SELECT>'; var myjTD3=mytable.rows[thisid].insertCell(-1); myjTD3.innerHTML="<INPUT TYPE='button' value='删除' οnclick='del(this,this.nextSibling.value)'><input id=ipt"+thisid+" type='hidden' value="+thisid+">"; rid++; } //删除当前指定的Row function del(obj,iptvalue) {         var delrow=obj.parentNode.parentNode;     delrow.parentNode.deleteRow(delrow.sectionRowIndex);         for(var i=0;i<rid;i++)     {          if(i>parseInt(iptvalue))         {             if(document.getElementById('ipt'+i))             {             var iptobj=document.getElementById('ipt'+i);             iptobj.value=i-1;             iptobj.id='ipt'+(i-1);             var cobj=document.getElementById('step'+i);             cobj.innerHTML="步骤"+i;             cobj.id='step'+(i-1);             document.getElementById('row'+i).id="row"+(i-1);             document.getElementById('selGroup'+i).id="selGroup"+(i-1);             document.getElementById('selUser'+i).id="selUser"+(i-1);             document.getElementById('examGroup'+i).id="examGroup"+(i-1);             document.getElementById('examUser'+i).id="examUser"+(i-1);             }         }     }     rid=rid-1; } //--> </SCRIPT> </head> <body>   <form id="frm">    <table align="center">            <tr>             <td>流程名:<input type="text" /></td>         </tr>         <tr>             <td>流程简介:<input type="text" /></td>         </tr>         <tr>             <td>             <table id="table1">                 <tr id="row0">                     <td id="step0">步骤1</td>                     <td>浏览用户:<select id="selgroup0"><option>选择用户组</option></select><select id="seluser0"><option>选择用户</option></select></td>                     <td>审批用户:<select id="selgroup0"><option>选择用户组</option></select><select id="seluser0"><option>选择用户</option></select></td>                     <td><input id=ipt0 type='hidden' value=0></td>                 </tr>             </table>             </td>          </tr>         <tr>             <td><input type="button" value="添加步骤" οnclick="creatTRTD()" /></td>         </tr>         <tr>           <td><input name="button" type="button" value="保存" /><input name="button" type="button" value="返回" /></td>         </tr>    </table>    </form> </body> </html>
转载请注明原文地址: https://www.6miu.com/read-82728.html

最新回复(0)