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); 

    }

  • 相关阅读:
    Go基础系列:流程控制结构
    Go基础系列:数据类型转换(strconv包)
    Go基础系列:简单数据类型
    Go基础系列:常量和变量
    Go基础系列:map类型
    Go基础系列:Go slice详解
    go基础系列:数组
    Go基础系列:import导包和初始化阶段
    Go基础系列:构建go程序
    go基础系列:结构struct
  • 原文地址:https://www.cnblogs.com/ranran/p/4081770.html
Copyright © 2011-2022 走看看