zoukankan      html  css  js  c++  java
  • JavaScript后台代码操作HTML TABLE的方法

    var rowNum = 0,fileNum = 0; //行号与列号 
    var oNewRow; //定义插入行对象 
    var oNewCell1,oNewCell2; //定义插入列对象 
    var fileNum = 1; 

    function addFileToTable(strFile) 

    fileNum +=1; 
    rowNum = document.getElementById("NewFileList").rows.length; 
    oNewRow = document.getElementById("NewFileList").insertRow(rowNum); 
    oNewRow.id = "clientRow_" + fileNum; 

    //添加第一列 
    oNewCell1 = document.getElementById("NewFileList").rows[rowNum].insertCell(0); 
    oNewCell1.innerHTML = "<input type='Text' readonly='readonly' style='border:0px;100px;' value='" + getFileName(strFile) + "' />"; 

    //添加第二列 
    oNewCell2 = document.getElementById("NewFileList").rows[rowNum].insertCell(1); 
    oNewCell2.innerHTML ="  <span name=" + fileNum + " style='cursor:hand;color:Red; text-decoration:none; font-family:@HGP?????E;' onClick='DelClientRow(this);' >X</span>"; 
    }

    ASP.NET后台代码操作HTML TABLE的方法  

    例1:该方法是读取服务器上路经为"strFilePath"的文件夹中的所有文件,并显示在页面上ID为"OldFileList"的TABLE中,注意,这个TABLE的"runat=server"。 
    public void ShowFilesIn(string strFilePath) 

    OldFileList.Rows.Clear(); 
    string[] strFileNames = GetFilesInServer(strFilePath); 
    for (int i = 0; i < strFileNames.Length; i++) 

    HtmlTableRow newRow = new HtmlTableRow(); 
    newRow.ID = "serverRow_" + i; 
    HtmlTableCell cell1 = new HtmlTableCell(); 
    HtmlTableCell cell2 = new HtmlTableCell(); 

    cell1.InnerHtml = "<input type='Text' readonly='readonly' style='border:0px;90px;' value='" + strFileNames[i] + "' />"; 
    cell2.InnerHtml = " <span name=" + strFileNames[i] + " style='cursor:hand;color:Red; text-decoration:none; font-family:@HGP?????E;' onClick='DelServerRow(this);' >X</span>"; 
    newRow.Cells.Add(cell1); 
    newRow.Cells.Add(cell2); 
    OldFileList.Rows.Add(newRow); 

    }

  • 相关阅读:
    POJ 3211 (分组01背包) Washing Clothes
    CodeForces 489D Unbearable Controversy of Being
    CodeForces 489C (贪心) Given Length and Sum of Digits...
    CodeForces 489B (贪心 或 最大匹配) BerSU Ball
    CodeForces 489A (瞎搞) SwapSort
    CodeForces 474.D Flowers
    UVa 1252 (状压DP + 记忆化搜索) Twenty Questions
    UVa 10817 (状压DP + 记忆化搜索) Headmaster's Headache
    【读书笔记】莫比乌斯函数与莫比乌斯反演
    UVa 11437 (梅涅劳斯定理) Triangle Fun
  • 原文地址:https://www.cnblogs.com/ranran/p/4081770.html
Copyright © 2011-2022 走看看