zoukankan      html  css  js  c++  java
  • JS表的行添加操作(insertRow)

    var rowCount = document.getElementById("dataTable").rows.length;
     

       var createCount;
        var tbObj = document.getElementById("dataTable");
        if(rowCount == 0){
         var rs = tbObj.rows;
         var count = rs.length;
         document.mainFrm.rowNewCount.value = 0;
         document.mainFrm.rowCount.value = 0;
         var newTr = tbObj.insertRow();
                   
         newTr.height="22";
         //newTr.style="cursor:'hand'";
         newTr.onMouseMove="style.backgroundColor='#EFEFEF'";
         newTr.onMouseOut="style.backgroundColor='#ffffff'";
        
         var newTd0 = newTr.insertCell();
         newTd0.width="3%";
         newTd0.align="center";
        
         var newTd1 = newTr.insertCell();
         newTd1.width="40%";
         newTd1.align="left";
        
         var newTd2 = newTr.insertCell();
         newTd2.width="40%";
         newTd2.align="left";
        
         newTd0.innerHTML = "<input type='checkbox' name='relationId' id='relationId' value=''>";
         newTd1.innerHTML = "<input type='text' name='orgCode' value='' class='noemptyInput' style=' 100%' onblur='ajaxValidateCode(this)'>";
         newTd2.innerHTML = "<input type='text' name='orgName' value='' class='noemptyInput' style=' 100%'>";
         createCount = count;
         createCount ++;
         document.mainFrm.createCount.value = createCount;
        } else {
         var rs = tbObj.rows;
         var count = rs.length;
         var row0 = rs[count - 1];
         var newRow = row0.cloneNode(true);
         newRow.firstChild.nextSibling.firstChild.value = "";
         newRow.lastChild.firstChild.value = "";
         if(document.mainFrm.rowCount.value == ""){
          document.mainFrm.rowCount.value = count;
         }
         createCount = count;
         createCount ++;
         document.mainFrm.createCount.value = createCount;
         row0.appendChild(newRow);
        }

  • 相关阅读:
    Extjs的学习及MIS系统实践应用(系列文章)
    Extjs的js函数
    【VS Code】使用技巧
    【算法技巧】算法技巧记录
    【踩坑记录】vs2017 git 版本控制问题
    【IDE】解决国内下载安装vs 过慢问题
    【c#基础】.Net编译器平台
    【查看IIS站点日志】
    【项目管理】人月神话
    【c#基础】反射、元数据和动态编程
  • 原文地址:https://www.cnblogs.com/zengxlf/p/1451100.html
Copyright © 2011-2022 走看看