精华内容
参与话题
问答
  • http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> http://www.w3.org/1999/xhtml"> 无标题文档 var rid=1; function creatTRTD(){ ...var mytable = document.getElementByI
    <!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>
    展开全文
  • js动态删除table中的一行的方法

    千次阅读 2018-08-18 15:17:10
    //得到对象 function getRowObj(obj) { var i = 0; while(obj.tagName.toLowerCase() != "tr"){ obj = obj.parentNode; if(obj.tagName.toLowerCase() == "table")return null; } ...
    //得到行对象 
    function getRowObj(obj) 
    { 
    var i = 0; 
    while(obj.tagName.toLowerCase() != "tr"){ 
    obj = obj.parentNode; 
    if(obj.tagName.toLowerCase() == "table")return null; 
    } 
    return obj; 
    } 
      
    //根据得到的行对象得到所在的行数 
    function getRowNo(obj){ 
    	var trObj = getRowObj(obj); 
    	var trArr = trObj.parentNode.children; 
    	for(var trNo= 0; trNo < trArr.length; trNo++){ 
    		if(trObj == trObj.parentNode.children[trNo]){ 
    		alert(trNo+1); 
    		} 
    	} 
    }
    
    //删除行 
    function delRow(obj){ 
    	var tr = this.getRowObj(obj); 
    	if(tr != null){ 
    		tr.parentNode.removeChild(tr); 
    	}else{ 
    		throw new Error("the given object is not contained by the table"); 
    	} 
    } 

     

    展开全文
  • 新增一行 附件: var currentDelId = -1; function addTr(){ var trNode = $("#firstTr").clone(); var _replaceHtml = trNode.html(); trNode =
    <div class="operate-btn">
        <ul>
            <li><a href="javascript:addTr()"><span>新增一行</span></a></li>
        </ul>
    </div>
    <tbody id="bxdtbdExp">
        <tr id="firstTr">
            <td style="width:120px">附件:</td>
            <td style="width:320px">
                <input type="file" name="files" /><br/>
            </td>
        </tr>
    </tbody>
    

    var currentDelId = -1;
    function addTr(){
        var trNode = $("#firstTr").clone();
        var _replaceHtml = trNode.html();
        trNode = null;
        var trrep = '<tr id="firstTr'+currentDelId+'">';
        replaceHtml = trrep + _replaceHtml + '<td><a href="javascript:removeTr(' + currentDelId + ')">[删除]</a></td>';
        $("#bxdtbdExp").append(replaceHtml + "</tr>");
        currentDelId--;
    };
    function removeTr(id){
        $("#firstTr"+id).remove();
    }





    展开全文
  • JS 更新删除一行

    千次阅读 2011-04-14 10:32:00
    //SystemManger.jsCode: //获取当前控件所在的 function getParent(src, tagName) { var par = src.parentElement; while (par.tagName.toLowerCase() != tagName) {

    //SystemManger.js

    Code:
    1. //获取当前控件所在的行   
    2. function getParent(src, tagName) {   
    3.     var par = src.parentElement;   
    4.     while (par.tagName.toLowerCase() != tagName) {   
    5.         par = par.parentElement;   
    6.     }   
    7.     return par;   
    8. }   
    9. //添加行   
    10. function AddNewRow(src) {   
    11.     var table = getParent(src, "table")   
    12.     var lastRow = table.rows[table.rows.length - 2];   
    13.     var newRow = table.insertRow(table.rows.length - 2);   
    14.     var cellsLength = lastRow.cells.length;   
    15.     var sIndex = 0;   
    16.     while (sIndex < cellsLength) {   
    17.         var newCell = newRow.insertCell();   
    18.         newCell.innerHTML = lastRow.cells[sIndex].innerHTML;   
    19.         if (sIndex == 0) {   
    20.             newCell.innerText = newRow.rowIndex;   
    21.         }   
    22.         sIndex++;   
    23.     }   
    24.     newRow.isNew = true;   
    25.     setRowOperEnable(newRow, false);   
    26. }   
    27. //编辑行   
    28. function SetEditModel(src, isEdit, isCancel) {   
    29.     var row = getParent(src, "tr");   
    30.     var cellsLength = row.cells.length;   
    31.     var startLength = 1;   
    32.     while (startLength < cellsLength - 1) {   
    33.         var cell = row.cells[startLength];   
    34.         if (isEdit) {   
    35.             cell.children[0].style.display = "none";   
    36.             cell.children[1].style.removeAttribute("display");   
    37.             if (cell.children[1].tagName.toLowerCase() != "select") {   
    38.                 cell.children[1].value = cell.children[0].innerHTML;   
    39.             }   
    40.             else {   
    41.                 var ops = cell.children[1].options;   
    42.                 for (var i = 0; i < ops.length; i++) {   
    43.                     var tempValue = ops[i].value;   
    44.                     if (tempValue == cell.children[0].innerHTML) {   
    45.                         ops[i].selected = true;   
    46.                     }   
    47.                 }   
    48.             }   
    49.         }   
    50.         else {   
    51.             cell.children[1].style.display = "none";   
    52.             cell.children[0].style.removeAttribute("display");   
    53.             if (!isCancel) {   
    54.                 cell.children[0].innerHTML = cell.children[1].value;   
    55.             }   
    56.         }   
    57.         startLength++;   
    58.     }   
    59.     var operCell = row.cells[cellsLength - 1];   
    60.     var srcText = src.innerText;   
    61.     var aLength = operCell.children.length;   
    62.     var astart = 0;   
    63.     if (row.isNew && srcText == "取消") {   
    64.         var table = getParent(src, "table");   
    65.         table.deleteRow(row.rowIndex);   
    66.         setRowOperEnable(table.rows[0], true);   
    67.         return;   
    68.     }   
    69.     if (row.isNew && srcText == "更新") {   
    70.         row.isNew = false;   
    71.     }   
    72.     if (srcText == "修改") {   
    73.         setRowOperEnable(row, false);   
    74.     }   
    75.     if (srcText == "更新" || srcText == "取消") {   
    76.         setRowOperEnable(row, true);   
    77.     }   
    78.     while (astart < aLength) {   
    79.         var child = operCell.children[astart];   
    80.         var childText = child.innerText;   
    81.         if (srcText == "修改") {   
    82.             if (childText == "修改" || childText == "删除") {   
    83.                 child.style.display = "none";   
    84.             }   
    85.             else {   
    86.                 child.style.removeAttribute("display");   
    87.             }   
    88.         }   
    89.         if (srcText == "更新" || srcText == "取消") {   
    90.             if (childText == "更新" || childText == "取消") {   
    91.                 child.style.display = "none";   
    92.             }   
    93.             else {   
    94.                 child.style.removeAttribute("display");   
    95.             }   
    96.         }   
    97.         astart++;   
    98.     }   
    99. }   
    100. //删除行   
    101. function deleteRow(src) {   
    102.     if (confirm('确认删除?')) {   
    103.         var row = getParent(src, "tr");   
    104.         var table = getParent(src, "table");   
    105.         table.deleteRow(row.rowIndex);   
    106.         setRowIndex(table);   
    107.         return true;   
    108.     }   
    109.     else {   
    110.         return false;   
    111.     }   
    112.   
    113. }   
    114. //设置行号   
    115. function setRowIndex(table) {   
    116.     var rows = table.rows;   
    117.     var sIndex = 1;   
    118.     var end = table.rows.length - 2;   
    119.     while (sIndex < end) {   
    120.         table.rows[sIndex].cells[0].innerText = sIndex.toString();   
    121.         sIndex++;   
    122.     }   
    123. }   
    124. function setRowOperEnable(row, enable) {   
    125.     var table = getParent(row, "table");   
    126.     var rowLength = table.rows.length;   
    127.     var cellLength = table.rows[0].cells.length;   
    128.     if (enable) {   
    129.         table.rows[rowLength - 1].cells[1].removeAttribute("disabled");   
    130.     }   
    131.     else {   
    132.         table.rows[rowLength - 1].cells[1].setAttribute("disabled""disabled");   
    133.     }   
    134.     var sIndex = 1;   
    135.     var end = rowLength - 2;   
    136.     while (sIndex < end) {   
    137.         if (sIndex != row.rowIndex) {   
    138.             if (enable) {   
    139.                 table.rows[sIndex].cells[cellLength - 1].removeAttribute("disabled");   
    140.             }   
    141.             else {   
    142.                 table.rows[sIndex].cells[cellLength - 1].setAttribute("disabled""disabled");   
    143.             }   
    144.         }   
    145.         sIndex++;   
    146.     }   
    147. }  

    //test.htm

    Code:
    1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    2. <html xmlns="http://www.w3.org/1999/xhtml">  
    3. <head>  
    4.     <title>部门</title>  
    5.   
    6.   
    7.     <script type="text/javascript" src="SystemManage.js"></script>  
    8.   
    9. </head>  
    10. <body>  
    11.     <div id="WapperDiv" style="float: left; background-color: White;">  
    12.         <table id="LayoutTable" cellpadding="0px" cellspacing="0px" style="width: auto; height: auto;">  
    13.             <tr id="TopTr">  
    14.                   
    15.             </tr>  
    16.             <tr id="CenterTr">  
    17.                 <td >  
    18.                 </td>  
    19.                 <td >  
    20.                     <div class="DocumentTitleDiv">  
    21.                         <label id="DocumentTitleLabel">  
    22.                             部门</label>  
    23.                     </div>  
    24.                     <div align="center">  
    25.                         <table>  
    26.                             <tr>  
    27.                                 <td>  
    28.                                     <label>  
    29.                                         部门名称</label>  
    30.                                     <input id="DepartmentName" type="text" class="SearchTextBox" />  
    31.                                 </td>  
    32.                                 <td>  
    33.                                 </td>  
    34.                                 <td>  
    35.                                     <input id="SearchButton" type="button" value="查询" class="button" />  
    36.                                 </td>  
    37.                                 <td>  
    38.                                 </td>  
    39.                             </tr>  
    40.                         </table>  
    41.                         <table id="departmenttable"  border ="1" cellspacing="0px" cellpadding="0px"  
    42.                             rules="none">  
    43.                             <thead>  
    44.                                 <tr >  
    45.                                     <th style="width: 33px;">  
    46.                                         序号   
    47.                                     </th>  
    48.                                     <th style="width: 81px;">  
    49.                                         部门名称   
    50.                                     </th>  
    51.                                     <th style="width: 81px;">  
    52.                                         电话   
    53.                                     </th>  
    54.                                     <th style="width: 81px;">  
    55.                                         联系人   
    56.                                     </th>  
    57.                                     <th style="width: 97px;">  
    58.                                         操作   
    59.                                     </th>  
    60.                                 </tr>  
    61.                             </thead>  
    62.                             <tr>  
    63.                                 <td>  
    64.                                     1   
    65.                                 </td>  
    66.                                 <td>  
    67.                                     <label>  
    68.                                         物资供应科</label>  
    69.                                     <input type="text" style="display: none"  />  
    70.                                 </td>  
    71.                                 <td>  
    72.                                     <label>  
    73.                                     </label>  
    74.                                     <input type="text" style="display: none"  />  
    75.                                 </td>  
    76.                                 <td>  
    77.                                     <label>  
    78.                                     </label>  
    79.                                     <input type="text" style="display: none"  />  
    80.                                 </td>  
    81.                                 <td>  
    82.                                     <a href="javascript:void(0);" onclick="SetEditModel(this,1)">修改</a> <a href="javascript:void(0);" onclick="return deleteRow(this);">  
    83.                                         删除</a> <a href="javascript:void(0);" style="display: none;" onclick="SetEditModel(this,0)">  
    84.                                             更新</a> <a href="javascript:void(0);" style="display: none;" onclick="SetEditModel(this,0,1)">  
    85.                                                 取消</a>  
    86.                                 </td>  
    87.                             </tr>  
    88.                             <tr style="display: none;">  
    89.                                 <td>  
    90.                                 </td>  
    91.                                 <td>  
    92.                                     <label style="display: none">  
    93.                                     </label>  
    94.                                     <input type="text"  />  
    95.                                 </td>  
    96.                                 <td>  
    97.                                     <label style="display: none">  
    98.                                     </label>  
    99.                                     <input type="text"  />  
    100.                                 </td>  
    101.                                 <td>  
    102.                                     <label style="display: none">  
    103.                                     </label>  
    104.                                     <input type="text"  />  
    105.                                 </td>  
    106.                                 <td>  
    107.                                     <a href="javascript:void(0);" style="display: none;" onclick="SetEditModel(this,1)">  
    108.                                         修改</a> <a href="javascript:void(0);" style="display: none;" onclick="return deleteRow(this);">删除</a> <a href="javascript:void(0);"  
    109.                                             onclick="SetEditModel(this,0)">更新</a> <a href="javascript:void(0);" onclick="SetEditModel(this,0,1)">  
    110.                                                 取消</a>  
    111.                                 </td>  
    112.                             </tr>  
    113.                             <tfoot>  
    114.                                 <tr>  
    115.                                     <td colspan="4" align="right" style="border-right: none;">  
    116.                                     </td>  
    117.                                     <td style="border-left: none;">  
    118.                                         <a href="javascript:void(0);" onclick="AddNewRow(this)">添加</a>  
    119.                                     </td>  
    120.                                 </tr>  
    121.                             </tfoot>  
    122.                         </table>  
    123.                     </div>  
    124.                 </td>  
    125.                 <td class="td3">  
    126.                 </td>  
    127.             </tr>  
    128.             <tr id="BottomTr">  
    129.                    
    130.             </tr>  
    131.             <tr>  
    132.                   
    133.             </tr>  
    134.         </table>  
    135.     </div>  
    136. </body>  
    137. </html>  

     

    展开全文
  • JS实现表格添加,删除一行

    万次阅读 2018-08-13 10:26:36
    &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;&lt;/title&... function addtr(){
  • js删除一行

    2007-06-26 13:42:36
      &...text/javascript"&gt;  function deleteFirst() {  var x = document.getElementById("first");  x.parentNode.removeChild(x);  }  &...
  •   &lt;script&gt; function rowsAdd(){ var Container = document.getElementById("play"); var detailNum = Container.rows.length; //var _table=document.getElementById... ...
  • JS新增一行或者删除一行

    千次阅读 2019-05-29 13:58:16
    Html代码: <li id="set-time"> <label style="width:22%;" for="alarm-time">时间</label> <span id="addtime_out" class="halves clearfix"> <span class="time-fields... <...
  • javascript在form表单中增加数据到表格中,也可以单独删除一行 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style>...
  • js实现删除一行

    千次阅读 2013-11-13 15:01:02
    javascript删除talbe中的一行    function Goto(){}  function deleteCurrentRow(obj){  var tr=obj.parentNode.parentNode;  var tbody=tr.parentNode;  tbody.removeChild(tr);  }        ...
  • js实现简单的动态添加或删除一行数据,(动态添加li)
  • JS 删除Table中的一行

    万次阅读 2012-11-27 16:57:58
    function deleteCurrentRow(obj){ var tr=obj.parentNode.parentNode; var tbody=tr.parentNode;... //只剩行首时删除表格 if(tbody.rows.length==1) { tbody.parentNode.remov
  • js指定tr添加一行,删除一行

    万次阅读 2016-08-09 14:14:18
     1 在此行下插入新  2 function instTR(){  var tab=document.getElementById('tab');  var n=document.getElementById('x').rowIndex+1;  var tr=tab.insertRow(n);  var td=tr.inser
  • 1:源代码 String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> "> ... gridPanel
  • 原生Js实现删除li标签一行内容

    千次阅读 2017-07-28 11:55:29
    原生Js实现删除li标签一行内容。 利用面向对象思想完成买家信息删除功能。
  • js动态表格添加一行删除一行保存一行
  • JS对table添加删除一行

    2015-12-15 17:29:47
    添加一行,并用AJAX提交数据。 function submitForm() { var name = $("#name").val(); var description = $("#description").val(); var url = $("#url").val(); $.ajax({ url: '/admin/ops', type:
  • Js删除table内的某一行

    千次阅读 2017-04-08 08:33:22
    //得到对象 function getRowObj(obj) { var i = 0; while(obj.tagName.toLowerCase() != "tr"){ obj = obj.parentNode; if(obj.tagName.toLowerCase() == "table")return null; } return obj; } //根据得到的...
  • js删除tr一行的解决方案

    千次阅读 2016-11-16 11:17:01
    //新增一行 function getNewRowStr(){ number++; var str = ''; str = ""  + ""   + "" + "请选择${pcbmxs}"  + "" + "请选择${fsbmxs}"  + "" + "请选择" + "遵医嘱" + "口服" + "按说明
  • js 动态表格添加一行删除一行

    千次阅读 2016-08-05 19:48:38
    js 动态表格添加一行删除一行

空空如也

1 2 3 4 5 ... 20
收藏数 196,135
精华内容 78,454
关键字:

js删除一行