CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
【经验总结】不能实施并行处理的情况 浅谈并行编程中的任务分解模式
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  JavaScript

请教:动态表格的生成

楼主xuchongde_1()2005-02-18 14:41:47 在 Web 开发 / JavaScript 提问

我要做一个动态表格,功能要求如下:  
  1   表格的行数不固定,可以通过按纽或者回车来动态添加一行。  
  2   给每行的td进行命名(每行有多个td)。  
  3   可进行校验。  
  请各位高手指点。 问题点数:100、回复次数:12Top

1 楼kingchang2000(骠骑大将)回复于 2005-02-18 15:38:08 得分 20

<html>  
  <head>  
  <style>  
      TR   {background-color:   white;   color:   black;   font-family:   verdana;   font-size:   20;   font-weight:   bold;}  
  </style>  
  <body   style="font-family:   verdana">  
  <h2>Table   Editor</h2>  
  <br>  
  <h3>Single   click   to   select   a   cell,   alt-click   to   select   a   row</h3>  
  <br>  
  <div   id=TableContainer>  
  <table   id=TheTable   border=1   style="border-collapse:   collapse;   table-layout:   fixed">  
      <tbody>  
            <tr><td>Cell   1,1</td><td>Cell   1,2</td><td>Cell   1,3</td></tr>  
            <tr><td>Cell   2,1</td><td>Cell   2,2</td><td>Cell   2,3</td></tr>  
            <tr><td>Cell   3,1</td><td>Cell   3,2</td><td>Cell   3,3</td></tr>  
      </tbody>  
  </table>  
  </div>  
   
  <br><br><br>  
   
  <input   id=ButtonAddRow   style="width:   200px;"   type=button   value="Add   Row"   onclick="addRow()"><br>  
  <input   id=ButtonRemoveRow   style="width:   200px;"   type=button   value="Remove   Row"   onclick="removeRow()"><br>  
  <input   id=ButtonAddCell   style="width:   200px;"   type=button   value="Add   Cell"   onclick="addCell()"><br>  
  <input   id=ButtonRemoveCell   style="width:   200px;"   type=button   value="Remove   Cell"   onclick="removeCell()"><br>  
  <input   id=ButtonMoveUp   style="width:   200px;"   type=button   value="Move   Up"   onclick="moveUp()"><br>  
  <input   id=ButtonMoveDown   style="width:   200px;"   type=button   value="Move   Down"   onclick="moveDown()"><br>  
  <input   id=ButtonMoveLeft   style="width:   200px;"   type=button   value="Move   Left"   onclick="moveLeft()"><br>  
  <input   id=ButtonMoveRight   style="width:   200px;"   type=button   value="Move   Right"   onclick="moveRight()"><br>  
  <input   id=ButtonEditContents   style="width:   200px;"   type=button   value="Edit   Contents"   onclick="editContents();">  
  <input   type=text   style="display:   none;   width:   400px;"   id=EditCell><br>  
  <input   id=ButtonEditStyle   style="width:   200px;"   type=button   value="Edit   Table   Style"   onclick="editStyle();">  
  <input   type=text   style="display:   none;   width:   400px;"   id=EditStyle><br>  
  <script>  
  var   lastSelection   =   null;  
   
  ButtonAddRow.setExpression("disabled",   "nothingSelected(lastSelection)");  
  ButtonRemoveRow.setExpression("disabled",   "!   rowSelected(lastSelection)");  
  ButtonAddCell.setExpression("disabled",   "nothingSelected(lastSelection)");  
  ButtonRemoveCell.setExpression("disabled",   "!   cellSelected(lastSelection)");  
  ButtonMoveUp.setExpression("disabled",   "!   rowSelected(lastSelection)");  
  ButtonMoveDown.setExpression("disabled",   "!   rowSelected(lastSelection)");  
  ButtonMoveLeft.setExpression("disabled",   "!   cellSelected(lastSelection)");  
  ButtonMoveRight.setExpression("disabled",   "!   cellSelected(lastSelection)");  
  ButtonEditContents.setExpression("disabled",   "(!   cellSelected(lastSelection))   ||   (EditCell.style.display   ==   '')");  
  ButtonEditStyle.setExpression("disabled",   "(EditStyle.style.display   ==   '')");  
  ButtonEditStyle.setExpression("value",   "'Edit   '   +   whatIsSelected(lastSelection)   +   '   Style'");  
   
  function   select(element)   {  
      var   e,   r,   c;  
      if   (element   ==   null)   {  
          e   =   window.event.srcElement;  
      }   else   {  
          e   =   element;  
      }  
      if   ((window.event.altKey)   ||   (e.tagName   ==   "TR"))   {  
          r   =   findRow(e);  
          if   (r   !=   null)   {  
              if   (lastSelection   !=   null)   {  
                  deselectRowOrCell(lastSelection);  
              }  
              selectRowOrCell(r);  
              lastSelection   =   r;  
          }  
      }   else   {  
          c   =   findCell(e);  
          if   (c   !=   null)   {  
              if   (lastSelection   !=   null)   {  
                  deselectRowOrCell(lastSelection);  
              }  
              selectRowOrCell(c);  
              lastSelection   =   c;  
          }  
      }  
   
      window.event.cancelBubble   =   true;  
  }    
   
  TableContainer.onclick   =   select;  
   
  function   cancelSelect()   {  
   
      if   (window.event.srcElement.tagName   !=   "BODY")    
          return;  
   
      if   (lastSelection   !=   null)   {  
          deselectRowOrCell(lastSelection);  
          lastSelection   =   null;  
      }  
  }  
   
  document.onclick   =   cancelSelect;  
   
  function   findRow(e)   {  
      if   (e.tagName   ==   "TR")   {  
          return   e;  
      }   else   if   (e.tagName   ==   "BODY")   {  
          return   null;  
      }   else   {  
          return   findRow(e.parentElement);  
      }  
  }  
   
  function   findCell(e)   {  
      if   (e.tagName   ==   "TD")   {  
          return   e;  
      }   else   if   (e.tagName   ==   "BODY")   {  
          return   null;  
      }   else   {  
          return   findCell(e.parentElement);  
      }  
  }  
   
  function   deselectRowOrCell(r)   {  
      r.runtimeStyle.backgroundColor   =   "";  
      r.runtimeStyle.color   =   "";  
      //r.runtimeStyle.fontFamily   =   "Verdana";  
  }  
   
  function   selectRowOrCell(r)   {  
      r.runtimeStyle.backgroundColor   =   "darkblue";  
      r.runtimeStyle.color   =   "white";  
      //r.runtimeStyle.fontFamily   =   "Verdana";  
  }  
  Top

2 楼kingchang2000(骠骑大将)回复于 2005-02-18 15:38:30 得分 20

function   addRow()   {  
      var   r,   p,   nr;  
      if   (lastSelection   ==   null)   {  
          r   =   null;  
          p   =   TheTable.children[0];  
      }   else   {  
          r   =   lastSelection;  
   
          if   (r.tagName   ==   "TD")   {  
              r   =   r.parentElement;  
          }  
   
          p   =   r.parentElement;  
      }  
   
      nr   =   document.createElement("TR");  
   
      p.insertBefore(nr,   r);  
   
      select(nr);  
   
      addCell();  
   
      return   nr;          
  }  
   
  function   removeRow()   {  
      var   r,   p,   nr;  
      if   (lastSelection   ==   null)  
          return   false;  
   
      r   =   lastSelection;  
   
      if   (r.tagName   ==   "TD")   {  
          r   =   r.parentElement;  
      }  
   
      p   =   r.parentElement;  
   
      p.removeChild(r);  
   
      lastSelection   =   null;  
     
      return   r;    
  }  
   
  function   addCell()   {  
      var   r,   p,   c,   nc,   text;  
      if   (lastSelection   ==   null)  
          return   false;  
   
      r   =   lastSelection;  
   
      if   (r.tagName   ==   "TD")   {  
          r   =   r.parentElement;  
          c   =   lastSelection;  
      }   else   {  
          c   =   null;  
      }  
   
      nc   =   document.createElement("TD");  
      text   =   document.createTextNode("New   Cell");  
   
      nc.insertBefore(text,   null);  
      r.insertBefore(nc,   c);  
   
      select(nc);  
   
      return   nc;  
  }  
   
  function   removeCell()   {  
      var   c,   p,   nr;  
      if   (lastSelection   ==   null)  
          return   false;  
   
      c   =   lastSelection;  
   
      if   (c.tagName   !=   "TD")   {  
          return   null;  
      }  
   
      p   =   c.parentElement;  
   
      p.removeChild(c);  
   
      lastSelection   =   null;  
     
      return   c;    
  }  
   
  function   editContents()   {  
      var   c,   p,   nr;  
      if   (lastSelection   ==   null)  
          return   false;  
   
      c   =   lastSelection;  
   
      if   (c.tagName   !=   "TD")   {  
          return   null;  
      }  
   
      EditCell.style.display   =   "";  
   
      EditCell.value   =   c.innerHTML;  
   
      c.setExpression("innerHTML",   "EditCell.value");  
   
      EditCell.focus();  
   
      EditCell.onblur   =   unhookContentsExpression;  
  }  
   
  function   unhookContentsExpression()   {  
      lastSelection.removeExpression("innerHTML");  
      EditCell.value   =   '';  
      EditCell.style.display   =   "none";  
  }  
   
  function   editStyle()   {  
      var   c;  
   
      if   (lastSelection   ==   null)   {  
          c   =   TheTable;  
      }   else   {  
          c   =   lastSelection;  
      }  
       
      EditStyle.style.display   =   "";  
   
      EditStyle.value   =   c.style.cssText;  
   
      c.style.setExpression("cssText",   "EditStyle.value");  
   
      EditStyle.focus();  
   
      EditStyle.onblur   =   unhookStyleExpression;  
  }  
   
  function   unhookStyleExpression()   {  
      var   c;  
   
      if   (lastSelection   ==   null)   {  
          c   =   TheTable;  
      }   else   {  
          c   =   lastSelection;  
      }  
      c.style.removeExpression("cssText");  
   
      EditStyle.value   =   '';  
      EditStyle.style.display   =   "none";  
  }  
   
  function   moveUp()   {  
      var   r,   p,   ls;  
      if   (lastSelection   ==   null)  
          return   false;  
   
      r   =   lastSelection;  
   
      if   (r.tagName   !=   "TR")   {  
          return   null;  
      }  
   
      if   (r.rowIndex   ==   0)    
          return;  
   
      ls   =   r.previousSibling;  
   
      p   =   ls.parentElement;  
   
      p.insertBefore(r,   ls);  
   
      return   r;  
  }  
   
  function   moveDown()   {  
      var   r,   p,   ls;  
      if   (lastSelection   ==   null)  
          return   false;  
   
      r   =   lastSelection;  
   
      if   (r.tagName   !=   "TR")   {  
          return   null;  
      }  
   
      ls   =   r.nextSibling;  
   
      if   (ls   ==   null)  
          return   null;  
   
      p   =   ls.parentElement;  
   
      ls   =   ls.nextSibling;  
   
      p.insertBefore(r,   ls);  
   
      return   r;  
  }  
   
  function   moveLeft()   {  
      var   c,   p,   ls;  
      if   (lastSelection   ==   null)  
          return   false;  
   
      c   =   lastSelection;  
   
      if   (c.tagName   !=   "TD")   {  
          return   null;  
      }  
   
      ls   =   c.previousSibling;  
   
      if   (ls   ==   null)  
          return   null;  
   
      p   =   ls.parentElement;  
   
      p.insertBefore(c,   ls);  
   
      return   c;  
  }  
   
  function   moveRight()   {  
      var   c,   p,   ls;  
      if   (lastSelection   ==   null)  
          return   false;  
   
      c   =   lastSelection;  
   
      if   (c.tagName   !=   "TD")   {  
          return   null;  
      }  
   
      ls   =   c.nextSibling;  
   
      if   (ls   ==   null)  
          return   null;  
   
      p   =   ls.parentElement;  
   
      ls   =   ls.nextSibling;  
   
      p.insertBefore(c,   ls);  
   
      return   c;  
  }  
   
  function   nothingSelected()   {  
      return   (lastSelection   ==   null);  
  }  
   
  function   rowSelected()   {  
      var   c;  
      if   (lastSelection   ==   null)  
          return   false;  
   
      c   =   lastSelection;  
   
      return   (c.tagName   ==   "TR")  
  }  
   
  function   cellSelected()   {  
      var   c;  
      if   (lastSelection   ==   null)  
          return   false;  
   
      c   =   lastSelection;  
   
      return   (c.tagName   ==   "TD")  
  }  
   
  function   whatIsSelected()   {  
      if   (lastSelection   ==   null)    
          return   "Table";  
      if   (lastSelection.tagName   ==   "TD")    
          return   "Cell";  
      if   (lastSelection.tagName   ==   "TR")  
          return   "Row";  
  }  
   
  </script>Top

3 楼zhaoxiaoyang(梅雪香@深圳)回复于 2005-02-18 15:40:14 得分 20

<html>  
  <head>  
  <title>无标题文档</title>  
  <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">  
  <script   language="javascript">  
  var   curRow=null;  
  function   selectRow(tr1){  
  if(curRow)  
  curRow.bgColor="#FFFFFF";  
  tr1.bgColor="e7e7e7";  
  curRow=tr1;  
  }  
  function   addRow(src){  
  var   newrow   =   src.insertRow(src.rows.length-1);  
  newrow.attachEvent("onclick",function(){selectRow(newrow);});  
  newrow.height=20;  
  var   i=4;  
  while(i--){  
  var   newcell   =   newrow.insertCell();  
  switch(i){  
  case   0:   newcell.innerHTML=   '<input   type="button"   onClick="javascript:delRow(this.parentElement.parentElement)"   value="删除此行">';break;  
  default:   newcell.innerHTML=div1.innerHTML;break;  
  }  
  }  
  }  
  function   delRow(src){  
  src.parentElement.deleteRow(src.rowIndex);  
  }  
  </script>  
  </head>  
   
  <body>  
  <table   id="tb"   width="100%"     border="1"   align="center"   cellpadding="1"   cellspacing="1"   style="border-collapse:collapse"   bordercolor="#111111">  
      <tr>  
          <th   scope="col"   width="25%">一</th>  
          <th   scope="col"   width="25%">二</th>  
          <th   scope="col"   width="25%">三</th>  
          <th   scope="col"   width="25%">四</th>  
      </tr>  
      <tr   id="blankRow"   onClick="addRow(this.parentElement)">  
          <td>&nbsp;</td>  
          <td>&nbsp;</td>  
          <td>&nbsp;</td>  
          <td>&nbsp;</td>  
      </tr>  
  </table>  
  <div   id="div1"   style="display:none   "><input   id="txt"   type="text"   style="width:97%;   background-color:#FFFFEF"></div>  
  </body>  
  </html>  
  Top

4 楼manyou(他山之石【养万头猪,行万里路】)回复于 2005-02-18 15:41:35 得分 20

供参考:  
  <HTML>  
  <HEAD>  
  <TITLE>   New   Document   </TITLE>  
  <META   NAME="Generator"   CONTENT="EditPlus">  
  <META   NAME="Author"   CONTENT="">  
  <META   NAME="Keywords"   CONTENT="">  
  <META   NAME="Description"   CONTENT="">  
  <style   type="text/css">  
  <!--  
  .style1   {  
  font-size:   18px;  
  font-weight:   bold;  
  }  
  td,div   {  
  font-size:   12px;  
  }  
  .bd   {  
  border-top:#000000   1px   solid;  
  border-left:#000000   1px   solid;  
  border-right:#000000   1px   solid;  
  border-bottom:#000000   1px   solid;  
  }  
  -->  
  </style>  
  <script>  
  var   rowNum   =   1;  
  function   addRow()   {  
  tr   =   document.all.theData.insertRow();  
  tr.height='20';  
  tr.style.background="#FFFFFF";  
  td0   =   tr.insertCell();  
  td0.align="center";  
  td0.insertAdjacentHTML("afterBegin",(rowNum+1));  
  td1   =   tr.insertCell();  
  td1.insertAdjacentHTML("afterBegin","<input   name='t11"   +   rowNum   +   "'   type='text'   size='12'   class='bd'>");  
  td2   =   tr.insertCell();  
  td2.insertAdjacentHTML("afterBegin","<input   name='t200"   +   rowNum   +   "'   type='text'   size='12'   class='bd'>");  
  td3   =   tr.insertCell();  
  td3.insertAdjacentHTML("afterBegin","<input   name='t20"   +   rowNum   +   "'   type='text'   size='20'   class='bd'>");  
  td4   =   tr.insertCell();  
  td4.insertAdjacentHTML("afterBegin","<input   name='t27"   +   rowNum   +   "'   type='text'   size='20'   class='bd'>");  
  td5   =   tr.insertCell();  
  td5.insertAdjacentHTML("afterBegin","<input   name='t29"   +   rowNum   +   "'   type='text'   size='20'   class='bd'>");  
  rowNum   +=   1;  
  }  
  function   allSub()   {  
  document.all.rowNum.value   =   rowNum;  
  form1.submit();  
  }  
  </script>  
  </HEAD>  
   
  <BODY>  
  <form   name="form1"   method="post"   action="allSave.jsp">  
  <table   width="700"   id='theData'   border="0"   align="center"   cellpadding="0"   cellspacing="1"   bgcolor="#d6dff7">  
      <tr   align="center"   bgcolor="#FFFFFF">  
          <td   height="30"   colspan="7"><span   class="style1">工程合同段</span></td>  
      </tr>  
      <tr   align="center"   bgcolor="#0099FF">  
          <td   width="32"   height="20">序号</td>  
          <td   width="100"   height="20">工程编号</td>  
          <td   width="101"   height="20">合同段号</td>  
          <td   width="169"   height="20">合同段名称</td>  
          <td   width="147"   height="20">建设地点</td>  
          <td   width="144"   height="20">建设规模</td>  
      </tr>  
      <tr   bgcolor='#FFFFFF'>  
          <td   height='20'   align="center"   bgcolor="#FFFFFF">1</td>  
          <td   height='20'><input   name='t110'   type='text'   size='12'   class='bd'></td>  
          <td   height='20'><input   name='t2000'   type='text'   size='12'   class='bd'></td>  
          <td   height='20'><input   name='t200'   type='text'   size='20'   class='bd'></td>  
          <td   height='20'><input   name='t270'   type='text'   size='20'   class='bd'></td>  
          <td   height='20'><input   name='t290'   type='text'   size='20'   class='bd'></td>  
      </tr>  
  </table>  
  <table   width="700"     border="0"   align="center"   cellpadding="0"   cellspacing="1">  
      <tr   align="center"   bgcolor="#FFFFFF">  
          <td   width="694"   height="20"><input   type="button"   name="asdsa"   value="加一行"   onClick="addRow()">  
                  <input   type="button"   name="ss"   value="批量提交"   onClick="allSub()"><input   type="hidden"   name="rowNum"   value=""></td>  
      </tr>  
  </table>  
  </form>  
  </BODY>  
  </HTML>Top

5 楼micker(希望下一代别再贫穷)回复于 2005-02-18 15:42:34 得分 20

var     theRowOfTheDynamicTable=null;//用于存放表格要添加的行的样式。      
     
  function     add_row(the_table){          
                        if(the_table==null)      
                                                return;      
                             
                        var     i=0;      
                        var     the_row,the_cell;      
                        var     row_index=-1;      
                        if(theRowOfTheDynamicTable==null){      
                                                theRowOfTheDynamicTable=new     Array();      
                                                var     baseTr=the_table.rows[2];      
                                                for(i=0;i<baseTr.cells.length;i++){      
                                                                        the_cell=baseTr.cells[i];      
                                                                        theRowOfTheDynamicTable[i]=the_cell.innerHTML;      
                                                }      
                        }      
                        row_index=the_table.rows.length;      
                        var     newrow=the_table.insertRow(row_index);      
                        for(i=0;i<theRowOfTheDynamicTable.length;i++){      
                                                the_cell=newrow.insertCell(i);      
                                                the_cell.align="center";      
                                                the_cell.innerHTML=theRowOfTheDynamicTable[i];      
                        }      
  }      
     
  function     get_Element(the_ele,the_tag){      
                        the_tag     =     the_tag.toLowerCase();      
                        if(the_ele.tagName.toLowerCase()==the_tag)      
                                                return     the_ele;      
                        while(the_ele=the_ele.offsetParent){      
                                                if(the_ele.tagName.toLowerCase()==the_tag)      
                                                                        return     the_ele;      
                        }      
                        return(null);      
  }      
     
  function     del_row(the_table){          
                        var     the_cell,the_row;      
                        var     i=0;      
                the_cell=get_Element(event.srcElement,"td");      
                        if(the_cell==null)     return;      
     
                        the_row=the_cell.parentElement.rowIndex;      
                        the_table.deleteRow(the_row);      
  }      
     
  function     up_row(the_table){          
                        var     the_cell,cur_row,up_row;      
                        var     i=0;      
                        the_cell=get_Element(event.srcElement,"td");      
                        if(the_cell==null)     return;      
                        if(the_table.rows.length<=1)     return;      
                             
                        cur_row=the_cell.parentElement;      
                        row_index=cur_row.rowIndex;      
                        if(row_index<=0)     return;      
                        up_row=the_table.insertRow(row_index-1);      
                             
                        for(i=0;i<cur_row.cells.length;i++){      
                                                the_cell=up_row.insertCell(i);      
                                                the_cell.align="center";      
                                                the_cell.innerHTML=cur_row.cells[i].innerHTML;      
                        }      
                        the_table.deleteRow(row_index+1);      
  }      
     
  function     down_row(the_table){          
                        var     the_cell,cur_row,down_row;      
                            var     i=0;      
                the_cell=get_Element(event.srcElement,"td");      
                        if(the_cell==null)     return;      
                             
                        if(the_table.rows.length<=1)     return;      
                             
                        cur_row=the_cell.parentElement;      
                        row_index=cur_row.rowIndex;      
                        if(row_index>=the_table.rows.length-1)     return;      
                             
                        down_row=the_table.insertRow(row_index+2);      
                             
                        for(i=0;i<cur_row.cells.length;i++){      
                                                the_cell=down_row.insertCell(i);      
                                                the_cell.align="center";      
                                                the_cell.innerHTML=cur_row.cells[i].innerHTML;      
                        }      
                        the_table.deleteRow(row_index);      
  }      
     
  function     insert_row(the_table){          
                        var     the_cell,the_row,temp,row_index,newrow;      
                            var     i=0;      
                the_cell=get_Element(event.srcElement,"td");      
                        if(the_cell==null)     return;      
                        if(the_table.rows.length<=0)     return;      
                        the_row=the_cell.parentElement;      
                        row_index=the_row.rowIndex;      
                        newrow=the_table.insertRow(row_index);      
                        for(i=0;i<the_row.cells.length;i++){      
                                                the_cell=newrow.insertCell(i);      
                                                the_cell.align="center";      
                                                the_cell.innerHTML=the_row.cells[i].innerHTML;      
                        }      
  }      
  Top

6 楼MYLiao(醉书生)回复于 2005-02-18 15:46:34 得分 0

markTop

7 楼xuchongde_1()回复于 2005-02-18 16:18:32 得分 0

谢谢各位大侠。如果要通过回车增加一行要怎么做,还有,javascript的函数能否提供点资料,不胜感激!!!!Top

8 楼xuchongde_1()回复于 2005-02-22 09:09:24 得分 0

现在要改为添加一行时插入一个select下拉列表,下拉列表的内容是从数据库里读出来的,每个下拉列表的内容是一样的,要怎么做。  
  代码如下:  
  <%@   taglib   uri="/WEB-INF/struts-bean.tld"   prefix="bean"   %>  
  <%@   taglib   uri="/WEB-INF/struts-html.tld"   prefix="html"   %>  
  <%@   page   import="weblogic.jdbc.rowset.*"%>  
  <%@   page   import="java.text.DateFormat"   %>  
  <%@   page   import="java.util.Date"   %>  
  <%@   page   import="com.agr.finance.FinanceBean"%>  
  <%@   page   import="com.agr.utils.*"%>  
  <%@   page   import="com.agr.utils.da.*"%>  
  <%@   page   import="weblogic.jdbc.rowset.*"%>  
  <%@   page   contentType="text/html;   charset=GB2312"   %>  
  <%  
  FinanceBean   financeBean=new   FinanceBean();  
                  String   cardId=(String)request.getAttribute("cardId");  
                  String   bookId=(String)session.getAttribute("bookId");  
                  String   employeeId=(String)request.getAttribute("employeeId");  
                  String   sql   =   "select   a.map_id   as   value,b.subject_name   as   name   from   FI_BOOK_SUBJECT_MAP   as   a,FI_SUBJECT   as   b   where   a.book_id   ='"   +bookId   +   "'   and   a.subject_id   =   b.subject_id";  
  %>  
  <html>  
  <head>  
  <title></title>  
  <link   rel="stylesheet"   type="text/css"   href="<%=request.getContextPath()%>/css/argccs.css">  
  </head>  
  <script   language="javascript">  
  <!--  
  var   rowNum   =   1;  
  function   addRow()   {  
  tr   =   document.all.theData.insertRow();  
  tr.height='20';  
  tr.style.background="#FFFFFF";  
  td0   =   tr.insertCell();  
  td0.insertAdjacentHTML("afterBegin","<input   name='remark"   +   rowNum   +   "'   type='text'/>");  
                  td1   =   tr.insertCell();  
  td1.insertAdjacentHTML("afterBegin","<input   name='mapId"+rowNum   +"'   style='width:82'><span   style='width:18;overflow:hidden'><select   onchange='mapId"+rowNum+".value=value'   style='width:100;margin-left:-82'><option   value='-1'>请选择</option><option   value='12'>ttt</option><option   value='13'>aaa</option></select></span>");  
  td2   =   tr.insertCell();  
  td2.insertAdjacentHTML("afterBegin","<input   name='lenderSum"   +   rowNum   +   "'   type='text'/>");  
  td3   =   tr.insertCell();  
  td3.insertAdjacentHTML("afterBegin","<input   name='debitSum"   +   rowNum   +   "'   type='text'/>");  
  rowNum   +=   1;  
  }  
  function   mySave()  
  {  
      document.credenceForm.actionCode.value="acl_actionCredenceIncomeSave";  
      document.credenceForm.rowNum.value=rowNum;  
      document.credenceForm.submit();  
  }  
  function   myNewCredence()  
  {  
      document.credenceForm.actionCode.value="acl_actionCredenceIncomeAdd";  
      document.credenceForm.submit();  
  }  
  -->  
  </script>  
  <body   bgcolor="#FFFFFF"   background="<%=request.getContextPath()%>/images/bg01.jpg"     leftmargin="0"   topmargin="0">  
  <html:form   action="/credenceAction"   method="post">  
  <table   width="100%"   border="0"   cellspacing="0"   cellpadding="0">  
      <tr>  
          <td   height="25"   bgcolor="EEEEEE"><strong>&nbsp;&nbsp;当前位置&gt;&gt;</strong>财务管理&gt;&gt;收款凭证  
          </td>  
      </tr>  
  </table>  
  <table   width="96%"   border="0"   align="center"   cellpadding="0"   cellspacing="0">  
      <tr>  
          <td   height="40">  
  <html:messages   id="msg"   name="message">  
  <li><bean:write   name="msg"/>  
  </html:messages>  
  </td>  
      </tr>  
  </table>  
  <table   width="96%"   border="0"   align="center"   cellpadding="0"   cellspacing="0">  
      <tr>  
          <td   colspan="3"><table   width="100%"   border="0"   cellspacing="0"   cellpadding="0">  
                  <tr>  
                      <td>  
                      <table   border="0"   cellspacing="0"   cellpadding="0">  
                              <tr>  
                                  <td   width="20"> </td>  
                                  <td><img   src="<%=request.getContextPath()%>/images/line_b_001.jpg"   width="6"   height="28"></td>  
                                  <td   background="<%=request.getContextPath()%>/images/line_bg002.jpg">&nbsp;<font   color="#FFFFFF">收款凭证</font>&nbsp;</td>  
                                  <td><img   src="<%=request.getContextPath()%>/images/line_b_003.jpg"   width="6"   height="28"></td>  
                              </tr>  
                          </table>  
                          </td>  
                      <td   width="4"   align="left"   valign="bottom"><img   src="<%=request.getContextPath()%>/images/bg002.gif"   width="1"   height="1"></td>  
                  </tr>  
              </table></td></tr>  
      <tr>  
          <td   width="1"   background="<%=request.getContextPath()%>/images/bg002.gif"><img   src="<%=request.getContextPath()%>/images/bg002.gif"   width="1"   height="1"></td>  
          <td   width="931"   align="center"   bgcolor="#FFFFFF"><table   width="100%"   border="0"   cellspacing="0"   cellpadding="0">  
                  <tr>  
                      <td   background="<%=request.getContextPath()%>/images/bg006.gif"   bgcolor="4791DE"><img   src="<%=request.getContextPath()%>/images/bg006.gif"   width="1"   height="9"></td>  
                  </tr>  
                  <tr>  
                      <td   align="center"   valign="top">  
                      <table   width="100%"   border="0"   cellspacing="10"   cellpadding="8">  
                      <tr>  
                      <td   align="center"   bgcolor="EEEEEE">  
                              <table   width="100%"   border="1"   cellpadding="0"   cellspacing="0"     bordercolorlight="#93979A"   bordercolordark="#ffffff">  
                                  <tr   align="center"   bgcolor="#D1D1D1"   height="25">  
                                                                                      <td   colspan="4">套帐名称:<font   size="+1"   color="red"><%=financeBean.getBookAccountNameById(bookId)%></font>  
                                                                                      </td>  
                                                                                  </tr>  
                                      <tr>  
                                                                                          <td   align="right">日期</td>  
                                                                                          <td   align="left"><html:text   property="loginTime"   readonly="true"></html:text></td>  
                                                                                          <td   align="right">编号</td>  
                                                                                          <td   align="left">收-<%=cardId%></td>  
                                                                                  </tr>  
                                                                                  <tr>  
                                                                                      <td   colspan="4">  
  Top

9 楼xuchongde_1()回复于 2005-02-22 09:10:23 得分 0

接上:  
                                                                                        <table   id='theData'   border="0"   align="center"   cellpadding="0"   bgcolor="#d6dff7">  
      <tr   align="center"   bgcolor="#0099FF">  
                                                                                                          <td   width="32"   height="20">摘&nbsp;&nbsp;&nbsp;&nbsp;要</td>  
                                                                                                          <td   width="100"   height="20">会计科目</td>  
            <td   width="101"   height="20">借方金额</td>  
                                                                                                            <td   width="169"   height="20">贷方金额</td>  
                                                                                                  </tr>  
      <tr   bgcolor='#FFFFFF'>  
          <td   height='20'><input   name='remark0'   type='text'/></td>  
                                                                                                                  <td   height='20'><input   name="mapId0"   style="width:82"><span   style="width:18;overflow:hidden">  
  <select   id="test"   onchange="mapId0.value=value"   style="width:100;margin-left:-82">  
                                                                                                                                      <option   value="-1">请选择</option>  
  <%  
                                                                                                                                  try  
                                                                                                                                  {  
                                                                                                                                  CachedRowSetImpl   result=DBFacade.getInstance().getRowSet(sql,null);  
                                                                                                                                  while(result.next())  
                                                                                                                                  {  
                                                                                                                                  %>  
  <option   value="<%=   result.getString("value")%>"><%=result.getString("name")%></option>  
                                                                                                                                <%  
                                                                                                                                  }  
                                                                                                                                  }  
                                                                                                                                  catch(Exception   ex)  
                                                                                                                                  {  
                                                                                                                                      ex.printStackTrace();  
                                                                                                                                  }  
                                                                                                                                %>  
  </select></span>  
                                                                                                                  </td>  
                                                                                                                  <td   height='20'><input   name='lenderSum0'   type='text'/></td>  
                                                                                                                  <td   height='20'><input   name='debitSum0'   type='text'/></td>  
                                                                                                </tr>  
                                                                                          </table>  
                                                                                      </td>  
                                                                                  </tr>  
                                                                                  <tr>  
                                                                                      <td   colspan="4">  
                                                                                          <table   align="center">  
                                                                                              <tr   align="center">  
                                                                                                  <td   align="center">制表人&nbsp;<font   size="+1"   color="red"><%=employeeId%></font>&nbsp;&nbsp;&nbsp;&nbsp;</td>  
                                                                                                  <td   align="center">审核人</td>  
                                                                                                  <td   align="center">附件张</td>  
                                                                                              </tr>  
                                                                                          </table>  
                                                                                      </td>  
                                                                                  </tr>  
                                                                                  <tr>  
                                                                                      <td   colspan="4">  
                                                                                          <table   width="700"     border="0"   align="center"   cellpadding="0"   cellspacing="1">  
      <tr   align="center"   bgcolor="#FFFFFF">  
          <td   align="center"   height="20"><html:button   property="button"   styleClass="button4"   value="加一行"   onclick="addRow()"   />  
                                                                                                                &nbsp;&nbsp;&nbsp;&nbsp;  
                                                                                                                <html:button   property="button"   styleId="acl_actionCredenceIncomeSave"   styleClass="button4"   value="保&nbsp;存"   onclick="mySave()"   />  
                  </td>  
                                                                                                  </tr>  
                                                                                          </table>  
                                                                                      </td>  
                                                                                  </tr>  
                                                                                  <tr   align="center">  
                                                      <td   colspan="4">  
                                                                                                          <html:button   property="button"   value="增加收款凭证"   styleId="acl_actionCredenceAdd"   styleClass="button6"   onclick="myNewCredence()"/>  
                                                                                                  </td>  
                                                  </tr>  
                          </table>  
                      </td>  
                  </tr>  
   
              </table>  
                      </td>  
                  </tr>  
              </table>   </td>  
          <td   width="4"   align="left"   valign="top"   background="<%=request.getContextPath()%>/images/line_02.jpg"><img   src="/market/images/line_01.jpg"   width="4"   height="3"></td>  
      </tr>  
      <tr>  
          <td   colspan="3"   valign="top"><table   width="100%"   border="0"   cellspacing="0"   cellpadding="0">  
                  <tr>  
                      <td   width="4"   valign="top"><img   src="<%=request.getContextPath()%>/images/line_06.jpg"   width="4"   height="4"></td>  
                      <td   height="4"   valign="top"   background="<%=request.getContextPath()%>/images/line_05.jpg"><img   src="<%=request.getContextPath()%>/images/line_05.jpg"   width="1"   height="4"></td>  
                      <td   width="4"   valign="top"><img   src="<%=request.getContextPath()%>/images/line_03.jpg"   width="4"   height="4"></td>  
                  </tr>  
              </table></td>  
      </tr>  
  </table>  
  <br>  
  <html:hidden   property="actionCode"   />  
  <html:hidden   property="rowNum"   />  
  <html:hidden   property="cardId"   value="<%=   cardId%>"   />  
  </html:form>  
  </body>  
  </html>  
  即在td1中要怎么改  
  td1   =   tr.insertCell();  
  td1.insertAdjacentHTML("afterBegin","<input   name='mapId"+rowNum   +"'   style='width:82'><span   style='width:18;overflow:hidden'><select   onchange='mapId"+rowNum+".value=value'   style='width:100;margin-left:-82'><option   value='-1'>请选择</option><option   value='12'>ttt</option><option   value='13'>aaa</option></select></span>");  
  请帮帮忙Top

10 楼hcqhappy(月坏)回复于 2005-02-23 13:39:17 得分 0

好   学习Top

11 楼operfume(橘子香水)回复于 2005-02-24 00:06:06 得分 0

有时间的话到www.bluec.com.cn的产品展示中去看,  
  进入安全性评价供电第三版,用户名999,口令9,里面数据管理的表格全部是动态的。Top

12 楼hcqhappy(月坏)回复于 2005-02-24 10:13:26 得分 0

operfume(橘子香水)     是你开发的吗   很棒啊     有时间指点下啊Top

相关问题

  • 请教如何生成动态表格??
  • 动态生成表格,详请见内!
  • 关于动态生成表格问题
  • 动态生成表格的问题(如何动态生成控件)
  • <高人>如何动态生成不规则表格,求动态生成表格方案 难
  • 使用JS,如何动态生成表格及表格中的按钮
  • 请问如何动态生成多个表格?
  • 在线等待:怎样更快的动态生成表格行;
  • 动态生成并枚举表格数组
  • 如何动态生成表格啊?!?!急!!写大家

关键词

  • bg
  • jpg
  • images
  • gif
  • height
  • line
  • width

得分解答快速导航

  • 帖主:xuchongde_1
  • kingchang2000
  • kingchang2000
  • zhaoxiaoyang
  • manyou
  • micker

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
惹火投票。。火热进行中...
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
CSDN网站24小时值班电话:13552009689
Copyright © 2000-2009, CSDN.NET, All Rights Reserved
GongshangLogo