table的tr和td的动态添加和删除

  1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
  2 <%@include file="/common/taglibs.jsp" %>
  3 <html:base target="_self" />
  4 <%@page import="epm.sp.syspara.para.webapp.util.ParaUtil"%>
  5 <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
  6 <html>
  7 <head>
  8 <title>Insert title here</title>
  9  <%@include file="/common/header.jsp"%>
 10 <link rel="stylesheet" type="text/css" href="../css/css_sdjn/proscheculing.css" />
 11 <link rel="stylesheet" type="text/css" href="../css/css_sdjn/fontype.css" />
 12 <script type="text/javascript" src="../assets/FusionCharts/FusionCharts.js"></script>
 13 <script type="text/javascript" src="../flexigrid/js/jquery-1.10.2.js"></script>
 14 <script type="text/javascript" src="../flexigrid/js/jquery-migrate-1.2.1.js"></script>
 15 <style>
 16 .tableStyle{
 17     border:1px solid #D7D7D7;
 18     cellpadding:0;
 19     cellspacing:0;
 20     width:720px;
 21     height:480px;
 22 }
 23 .tableStyle tr td{
 24     border:1px solid #D7D7D7;
 25     cellpadding:0;
 26     cellspacing:0;
 27     font-size:14px;
 28     text-align:center;
 29 }
 30 tr.tableTitle{
 31     background-color:#E4E4E4;
 32 }
 33 .fontSyle{
 34     color: #777777;
 35     font-size:14px;
 36 }
 37 .tableTitle td {
 38     color: #777777;
 39     font-weight:bold;
 40     width:90px;
 41 }
 42 .SD_lowerLimit {
 43     position:relative;
 44     left:30px;
 45     width:31px;
 46     height:24px;
 47     background-image:url(../css/css_sdjn/images/middle/c_17.png);
 48     background-repeat: no-repeat;
 49     margin-top:10px;
 50 }
 51 .SD_upperLimit {
 52     position:relative;
 53     left:30px;
 54     width:31px;
 55     height:24px;
 56     background-image:url(../css/css_sdjn/images/middle/c_14.png);
 57     background-repeat: no-repeat;
 58     margin-top:10px;
 59 }
 60 </style>
 61 <%@include file="/common/header.jsp"%>
 62 <%
 63     String time = ParaUtil.getSysParaValue(request, "RELOAD_GRID_TIME");
 64 %>
 65 </head>
 66 <!--  -->
 67 <body style="margin:0;overflow:auto;background-color:transparent;">
 68     <html:form action="/mpsm/jproscheculing/warehousing/warehousing"
 69             method="post" styleId="mpsm_jproscheculing_wareHousingForm"
 70             onsubmit="return validateForm(this)">
 71
 72         <html:hidden property="trSize"/>
 73         <!-- 左上 左边 -->
 74         <div style="position:absolute;top:0px;left:0px;width:730px;height:280px;">
 75             <span class="box_h535_left"></span>
 76             <span class="box_h535_middle" style="width:700px;">
 77                 <div class="fontType" id = "location">库存情况</div>
 78             </span>
 79             <span class="box_h535_right" style="left:715px"></span>
 80         </div>
 81         <div align="center" style="position:absolute;top:40px;left:1px;">
 82             <!-- 进度条-->
 83             <div style="position:absolute;left:0px;top:20px;width:300px;height:500px;margin:0; ">
 84                 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="70%" height="90%"
 85                    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"
 86                    id="wareRate">
 87                    <param name="movie" name="usedTime" value="<%=request.getContextPath()%>/mpsm/jproscheculing/assets/flash/wareHousingRate.swf" />
 88                    <param name="quality" value="high" />
 89                    <param name="wmode" value="transparent" />
 90                    <param name="allowScriptAccess" value="sameDomain" />
 91                    <param name="allowFullScreen" value="true" />
 92                    <embed src="<%=request.getContextPath()%>/mpsm/jproscheculing/assets/flash/wareHousingRate.swf" quality="high" width="100%" height="100%"
 93                         name="wareRate" align="middle" play="true" loop="false" quality="high"
 94                         allowScriptAccess="sameDomain" womode="transparent"
 95                         type="application/x-shockwave-flash"
 96                         pluginspage="http://www.adobe.com/go/getflashplayer">
 97                     </embed>
 98                  </object>
 99             </div>
100             <!-- 饼状图 -->
101             <div style="position:absolute;left:320px;top:20px;width:300px;height:500px;margin:0; ">
102                 <div class="fontType2"><span id ="changePosition">省级计量中心</span>库存设备构成情况</div>
103                 <div id="wareEquipCategChartDiv"></div>
104             </div>
105         </div>
106         <!-- 左上 右边 -->
107         <div style="position:absolute;top:0px;left:2050px;width:730px;height:280px;">
108             <span class="box_h535_left"></span>
109             <span class="box_h535_middle" style="width:700px;">
110                 <div id = "twoLevelWareHouseInfo" class="fontType" style="cursor:pointer" >二级库存信息</div>
111             </span>
112             <span class="box_h535_right" style="left:715px"></span>
113         </div>
114         <div style="position:absolute;top:42px;left:2054px;">
115             <table id ="twoLevelWareHouseContext" class="tableStyle" border="1px"  bordercolor="#D7D7D7" cellpadding="0" cellspacing="0" width="720px" height="250px">
116                 <tr class="tableTitle">
117                     <td>单位</td>
118                     <td>单相</td>
119                     <td>三相</td>
120                     <td>电流互感器</td>
121                     <td>电压互感器</td>
122                     <td>采集器</td>
123                     <td>集中器</td>
124                     <td>专变终端</td>
125                 </tr>
126             </table>
127         </div>
128     </html:form>
129 </body>
130
131 <script type="text/javascript">
132     var form = document.forms[0];
133     window.onload=function(){
134         //设置进度条flash的进度
135         var rate = <%=request.getAttribute("wareRate")%>;
136         document.getElementById("wareRate").setOption(rate);
137
138         //初始化饼状图
139         var wareEquipCategChartXML1 = "<%=request.getAttribute("wareEquipCateg")%>";
140           setEquipCategInfoChartXML(wareEquipCategChartXML1);
141
142          //设置表格
143          var tableDataList = <%=request.getAttribute("tableDataList")%>;
144          initTableDate(eval(tableDataList));
145     }
146     var twoLevelWareHouseContext = document.getElementById("twoLevelWareHouseContext");
147     function initTableDate(tableData,isAjax){
148         //清空数据
149         if(isAjax=="isAjax"){
150             clearTwoLevelWareHouseContext();
151         }
152         //构建table并往里面填写数据
153         for(var i=1 ;i< tableData.numData.length+1; i++){
154             //动态的生成tr
155             twoLevelWareHouseContext.insertRow(i);
156             //动态的生成td
157             for(var j=0; j<8 ;j++){
158                 twoLevelWareHouseContext.rows[i].insertCell();
159             }
160             //填充数据
161             var trData = tableData.numData[i-1];
162             var styleConent = " "+trData.dxf+trData.sxf+trData.dlhgqf+trData.dyhgqf+trData.zbzdf+trData.jzqf+trData.cjqf;
163             twoLevelWareHouseContext.rows[i].cells[0].innerHTML = "<span id=orgName"+i+" class=‘fontSyle‘>"+trData.orgName+"</span>";
164             twoLevelWareHouseContext.rows[i].cells[1].innerHTML = "<div class = ‘"+trData.dxf+"‘><span class=‘fontSyle‘>"+trData.dx+"</span></div>";
165             twoLevelWareHouseContext.rows[i].cells[2].innerHTML = "<div class = ‘"+trData.sxf+"‘><span class=‘fontSyle‘>"+trData.sx+"</span></div>";
166             twoLevelWareHouseContext.rows[i].cells[3].innerHTML = "<div class = ‘"+trData.dlhgqf+"‘><span class=‘fontSyle‘>"+trData.dlhgq+"</span></div>";
167             twoLevelWareHouseContext.rows[i].cells[4].innerHTML = "<div class = ‘"+trData.dyhgqf+"‘><span class=‘fontSyle‘>"+trData.dyhgq+"</span></div>";
168             twoLevelWareHouseContext.rows[i].cells[5].innerHTML = "<div class = ‘"+trData.zbzdf+"‘><span class=‘fontSyle‘>"+trData.zbzd+"</span></div>";
169             twoLevelWareHouseContext.rows[i].cells[6].innerHTML = "<div class = ‘"+trData.jzqf+"‘><span class=‘fontSyle‘>"+trData.jzq+"</span></div>";
170             twoLevelWareHouseContext.rows[i].cells[7].innerHTML = "<div class = ‘"+trData.cjqf+"‘><span class=‘fontSyle‘>"+trData.cjq+"</span></div>";// "SD_lowerLimit"
171             if(styleConent.indexOf("SD_lowerLimit")>0){
172                 document.getElementById("orgName"+i).style.color=‘#00FA00‘;
173             }
174             if(styleConent.indexOf("SD_upperLimit")>0){
175                 document.getElementById("orgName"+i).style.color=‘#F296F‘;
176             }
177             if(styleConent.indexOf("SD_lowerLimit")>0&&styleConent.indexOf("SD_upperLimit")>0){
178                 document.getElementById("orgName"+i).style.color=‘red‘;
179             }
180         }
181         form.trSize.value=tableData.numData.length;
182     }
183
184     function clearTwoLevelWareHouseContext(){
185         for(var i=0;i<form.trSize.value; i++){
186             twoLevelWareHouseContext.deleteRow(1);
187         }
188     }
189
190     function setEquipCategInfoChartXML(wareEquipCategChartXML){
191         var chart1 = new FusionCharts("../assets/FusionCharts/Pie3D.swf","myChartId1", "360", "400");
192         //初始化的chart1不能放在setEquipCategInfoChartXML方法的外面,或出现组件中文乱码
193         chart1.setTransparent(true);
194            chart1.setDataXML(wareEquipCategChartXML);
195            chart1.render("wareEquipCategChartDiv");
196     }
197        //根据点击的地图上不同的地市 查询出该地市的单位库存占比
198        function loadXMLDoc(org_no,orgName,levelInfo){
199         var url = "<%=request.getContextPath()%>/mpsm/jproscheculing/warehousing/twolevelwarehousing.do?action=initLeftTop&isAjax=Y&org_no="+org_no;
200         jQuery.post(url,function(data){
201             //alert("org_no:"+org_no+"orgName:"+orgName+"levelInfo:"+levelInfo);
202             //库存占比 进度条
203             document.getElementById("changePosition").innerHTML=orgName;
204             document.getElementById("twoLevelWareHouseInfo").innerHTML=levelInfo;
205             document.getElementById("wareRate").refresh(data.wareRate);
206             //初始化饼状图
207             var chartObj = getChartFromId("myChartId1");
208             chartObj.setDataXML(data.wareEquipCategChartXML);
209             //setEquipCategInfoChartXML(data.wareEquipCategChartXML);
210             //设置表格
211             initTableDate(data.tableDataList,"isAjax");
212         },"json");
213       }
214
215 </script>
216
217 </html>

主要使用了insertCell、insertRow和deleteRow方法

时间: 2024-10-17 20:11:49

table的tr和td的动态添加和删除的相关文章

js在table指定tr行上或底下添加tr行

js在table指定tr行上或下面添加tr行 function onAddTR(trIndex)         {             var tb = document.getElementById("tb1");             var newTr = tb.insertRow(trIndex);//添加新行,trIndex就是要添加的位置             var newTd1 = newTr.insertCell();             newTd1.

jQuery如何动态添加具有删除按钮的行

jQuery如何动态添加具有删除按钮的行:在实际用中,如果要操作表格的话,那最多的莫过于添加和删除行的操作,一般情况下,动态添加的行也可以动态删除,下面就简单介绍一下如何实现此操作,虽然比较简单,但是还是希望能够或多或少能够给需要的朋友带来一定的帮助.代码实例如下: <!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author"

js动态添加和删除标签

html代码 <h1>动态添加和删除标签</h1> <div id="addTagTest"> <table> <thead><tr><th>姓名</th><th>年薪</th><th>操作</th></tr></thead> <tbody id="info"> </tbody>

RecyclerView动态添加、删除及点击事件

上一节讲解了RecyclerView的三种显示方式,本节将主要研究一下RecyclerView的动态添加.删除及其单击和长按事件的处理.我们在上一节代码的基础上进行相关操作. 一.修改适配器类MyAdapter,加入添加和删除这两个方法: public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> { private Context context; private List<String>

一个Spring Scheduler (Quartz) 动态添加,删除,修改任务的例子

要求 根据任务清单执行不定数量,不定频率的定时任务.并且需要动态添加,删除,修改任务. 代码 public class JobExample {      public static void main(String[] args) throws Exception {         // Job的配置信息,可以从数据库或配置文件中获取         List<JobParameter> list = new ArrayList<JobParameter>();        

JqueryMobile为Listview动态添加、删除查询功能

JqueryMobile的版本不同,引用JS的API也不同,因此为Listview动态添加.删除查询功能的代码也不同. 假设Listview控件内容如下: <ul data-role="listview" id="listview"  data-inset="true"> <li><a href="#">Acura</a></li> <li><a h

Unity NGUI中动态添加和删除sprite

转自:http://www.cnblogs.com/vitah/p/3897664.html (以后,参考链接和作者将在文章首部给出,转载请保留此部分内容) 参考链接:http://www.narkii.com/club/thread-299977-1.html,作者:纳金网 比巴卜: 参考链接:http://game.ceeger.com/forum/read.php?tid=2852,作者:Unity圣典论坛 kuku小夭 动态添加和删除Sprite可以在很多地方用到,这里以实现显示技能CD

在页面上动态添加和删除【添加信息的文本框】

页面上的内容: 当点击添加或删除会做出相应的操作 页面的html代码 1 <li id="clid"> 2 <div> 3 姓名:<input type="text" name="guestName" class="dfinput" style="width: 150px;"/> 4     国别:<input name="guestState"

hadoop集群 动态添加或删除节点

在运行中的ambari hadoop集中中动态添加或删除节点 1. 下线hdfs节点 1) 下线datanode namenode节点上dfs.exclude文件,看配置文件怎么配置的,里每行添加一个服务器名,如我要下线server7,server8,server9,则如下: server7 server8 备注: 如果hdfs-site.xml没有找到dfs.hosts.exclude,那么就手动把下面内容加入到hdfs-site.xml中,然后把需要Decommission的机器写到文件/e