日期:2014-05-16  浏览次数:20397 次

如何js实现克隆行
<table border="1" id="table1">
  <thead>
  <tr id="row1" name="row1">
  <td></td>
  <%
  for(int i=0;i<list.size();i++)
  {
  TemplatesInfo tempInfo=(TemplatesInfo)list.get(i);
 
  %>
  <td align="center"><input type="hidden" id="column<%=i %>" value="<%=tempInfo.getTemplateCoulmnName() %>"></td>
  <%
  }
  %>
  <td></td>
  </tr>
  </tr>
  <tr>
  <th align="center">序号</th>
  <%
  for(int i=0;i<list.size();i++)
  {
  TemplatesInfo tempInfo=(TemplatesInfo)list.get(i);
 
  %>
  <th align="center"><%=tempInfo.getTemplateCoulmnName() %></th>
  <%
  }
  %>
  <th><a href="javascript:void(0)" onclick="addRow()">增行</a>&nbsp;&nbsp;</th>
  </tr>
  <%
  if(proNumberList==null||proNumberList.size()==0)
  {
  return;
  }
  for(int i=0;i<proNumberList.size();i++){
  String proNumber=proNumberList.get(i).toString();
  %>
  <tr>
  <td align="center"><%=i+1 %></td>
  <%
  List proColumnInfoList=pis.findProjectByProNumber(proNumber);
  for(int j=0;j<proColumnInfoList.size();j++){
  String columnInfo=proColumnInfoList.get(j).toString();
  %>
  <td align="center"><input type="text" id="columnInfo" value="<%=columnInfo %>"></td>
  <%
  }
  %>
  </tr>
  <%
  }
  %>
  </thead>
  </table>
表的结构全是从数据库读取的,列不是固定的。
想要克隆第一行作为添加行的样本。如何添加。求大神编码