首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

怎么为动态表格添加行

2012-01-22 
如何为动态表格添加行由于当中有几列是动态读出来的,这样的行怎么添加才好呢表格源代码如下,还有新添加的

如何为动态表格添加行
由于当中有几列是动态读出来的,这样的行怎么添加才好呢
表格源代码如下,还有新添加的行的name也要按照第一行的来排下去
比如说第一行的 <td> <input   type= "text "   name= "fileno1 "> </td> 这一列
新的一行里就得为 <td> <input   type= "text "   name= "fileno2 "> </td> 这样一直下去

[code=Java]
    <table   id= "table1 "   width= "95% "   cellpadding= "0 "   cellspacing= "0 "     align= "center ">
        <tr>
                  <td   height= "31 "   width= "3% "   > <div   align= "center "> 序号 </div> </td>
                  <td   width=10% "> <div   align= "center "> 文号 </div> </t>
                  <td   width= "30% "> <div   align= "center "> 题名 </div> </td>
                  <td   width= "5% "> <div   align= "center "> 页次 </div> </td>
                  <td   width= "8% "> <div   align= "center "> 日期 </div> </td>
                  <td   width= "8% "> <div   align= "center "> 责任人 </div> </td>
        <%oFileInfo.getTypeInfos(Long.parseLong(dossertype));
        while(oFileInfo.goNext()){%>
                  <td   width= "8% "> <div   align= "center "> <%=oFileInfo.getTitle()   %> </div> </td>
        <%}oFileInfo.Close();   %>
          <td   width= "5% "> <div   align= "center "> 备注 </div> </td>
        <%if(up){   %>
                  <td   width= "10% "> <div   align= "center "> 电子源文件 </div> </td> <%   }%>
              </tr>

                    <tr   >
                <td   ondblclick= "showmenume(event, '   <div   class=menuiems> '   +
                    ' <input   type=text   name=buttonnew3   value=     行拷贝       style=CURSOR:   hand   onclick=javaScript:copyline(1);> </div> '   +
                    ' <input   type=text   name=buttonnew3   value=     行粘贴       style=CURSOR:   hand   onclick=javaScript:pasteline(1);> </div> ') ">
                      <input   type= "text "   name= "seqno1 "   value= "1 "   readonly= "readonly "   style= "width:100%;border:   thin   solid   #FFFFFF; "   onclick= "selected(1) "> </td>


                              <td> <input   type= "text "   name= "fileno1 "   value= " "   style= "width:100%;border:   thin   solid   #FFFFFF; "   onfocus= "javascript:setCurRow(1) "> </td>
                              <td> <input   type= "text "   name= "filename1 "   value= " "   style= "width:100%;border:   thin   solid   #FFFFFF; "   onfocus= "javascript:setCurRow(1) "   ondblclick= "javascript:showTitle( <%=dossertype%> ,1) "> </td>
                              <td> <input   type= "text "   name= "pageno1 "   value= " "     style= "width:100%;border:   thin   solid   #FFFFFF; "   onfocus= "javascript:setCurRow(1) "> </td>
                              <td> <input   type= "text "   name= "setupdate1 "   value= " "   style= "width:100%;border:   thin   solid   #FFFFFF; "onfocus= "javascript:setCurRow(1) "   onclick= "getDateString(this,oCalendarChs) "> </td>
                              <td> <input   type= "text "   name= "chargeman1 "   value= " "   style= "width:100%;border:   thin   solid   #FFFFFF; "   onfocus= "javascript:setCurRow(1) "   > </td>
        <%oFileInfo.getTypeInfos(Long.parseLong(dossertype));
        while(oFileInfo.goNext()){%>
                        <td> <input   type= "text "   name= " <%=oFileInfo.getFieldName()%> 1 "   value= " "   style= "width:100%;border:   thin   solid   #FFFFFF; "   onfocus= "javascript:setCurRow(1) "   > </td>
        <%}oFileInfo.Close();   %>
                              <td> <input   type= "text "   name= "beizhu1 "   value= " "   style= "width:100%;border:   thin   solid   #FFFFFF; "   onfocus= "javascript:setCurRow(1) "   onkeypress= "javascript:insertRow(1, <%=dossertype%> ) "> </td>
                                <%if(up){   %>   <td> <div   align= "center "   onclick= "getdn() "> 添加 </div> </td> <%}   %>
              </tr>
</table>
[/code]

[解决办法]
http://community.csdn.net/Expert/TopicView3.asp?id=5552705
看看 这个对你有帮助没有
[解决办法]
使用多维数组,现查询处所有的结果,通过获取rs的行数和列数,动态添加到数组中,再读取,如何获取行数和列数可以参看:http://blog.csdn.net/jiqimiao/archive/2007/05/21/1619532.aspx



[解决办法]
给你一个添加,删除的列子,自己改一下

<HTML>
<SCRIPT LANGUAGE= "JScript ">
function numberCells()
{
var count=0;
for (i=0; i < document.all.mytable.rows.length; i++)
{
for (j=0; j < document.all.mytable.rows(i).cells.length; j++)
{
document.all.mytable.rows(i).cells(j).innerText = count;
count++;
}
}
}

function tb_addnew()
{
var ls_t=document.all( "mytable ")
maxcell=ls_t.rows(0).cells.length;
mynewrow = ls_t.insertRow();
for(i=0;i <maxcell;i++)
{
mynewcell=mynewrow.insertCell();
mynewcell.innerText= "a "+i;

}
}

function tb_delete()
{
var ls_t=document.all( "mytable ");

ls_t.deleteRow() ;
}

</SCRIPT>
<BODY onload= "numberCells() ">
<TABLE id=mytable border=1>
<TR> <TH> </TH> <TH> </TH> <TH> </TH> <TH> </TH> </TR>
<TR> <TD> </TD> <TD> </TD> <TD> </TD> <TD> </TD> </TR>
<TR> <TD> </TD> <TD> </TD> <TD> </TD> <TD> </TD> </TR>
</TABLE>
<input type=button value= "增加 " onclick= "tb_addnew() ">
<input type=button value= "删除 " onclick= "tb_delete() " >
</BODY>
</HTML>

热点排行