按一个按钮,增加下面的一个tr,也可删除
这个问题比较难,大家有什么指点?
<tr >
<td style="height:30px; width:18px;"></td>
<td bgcolor="#F3F4F6" style="height:30px; width:202px;" align="left">
                                                        &nbsp;導師1員工編號&nbsp;</td>
<td style="height:30px; width:16px;">:</td>
<td align="left" style="height:30px; width:236px;">
                                                        <asp:TextBox ID="txtEmpno1" onkeydown="enter()" runat="server" Width="184px" MaxLength="8"></asp:TextBox><img id="Img4" runat="server" align="absMiddle" alt="選擇工號" height="20" onclick="window.open('BrowseEmployee.aspx?currcontrolid=2'+'&facnum='+$F('SelFacNum')+'&deptnum='+$F('SelDeptNum') ,'win01','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=850,height=500,top='+(screen.height-380)/2+',left='+(screen.width-800)/2)"
                                                            onmouseover="this.style.cursor='hand'" src="images/cmdBrowse.gif" width="21" /></td>


<td >
                                                    <strong><span style="color: #ff0000"></span></strong></td>
<td bgcolor="#F3F4F6" style="height:30px; width:202px;" align="left">
                                                        &nbsp; 導師1名稱&nbsp;</td>
<td style="height:30px; width:3px;">:</td>
<td align="left" style="height:30px; width:245px;">
<asp:textbox id="lblNamChn1" onkeydown="enter()" runat="server" Width="192px"
CssClass="Border" MaxLength="20"></asp:textbox>
                                                        </td>
</tr>

解决方案 »

  1.   

    Javascript只能增加客户端控件按
      

  2.   

    可以在客户端使用js追加行
    也可以在服务端,使用asp:table控件,然后往里面扔TableRow,--建议看一下  Table TableRow  TableCell这三个类。非常方便实用
            
      

  3.   


    那你想干什么,想增加服务器端的控件???那你的table就用<asp:table>
      

  4.   

    给个例子你:
    <script>
    var attIndex=0;function adddiv(){
      var attDiv = document.createElement("div");
      attDiv.innerHTML = "测试"+attIndex;
      attDiv.id="attDiv_"+attIndex;
      document.body.appendChild(attDiv);
      var attDel = document.createElement("a");
      attDel.id = "attlink_" + attIndex;
      attDel.href = "#";
      attDel.innerHTML = "删除";
      attDel.onclick = function() { document.body.removeChild(attDiv);}
      attDiv.appendChild(attDel);
      attIndex++ ; 
    }
    </script>
    <input type="button" value="增加" onclick="adddiv()">
      

  5.   

    JS,服务器控件应该不好搞,JS调用写的话,服务器控件不能识别
    楼上已经给例子了这里就不再贴代码了,都差不多的
      

  6.   

    我不喜欢在后台去生成那些东西,用户体验不好,刷新下搞得以前填的东西都没了,尤其是下拉列表。这种还是建议js操纵Dom。