js部分
<script language="javascript" type="text/javascript">
var count=0 ;
function additem(id)
{
var row,cell,str;
row = document.getElementById(id).insertRow(count+1);
if(row != null )
{
row.insertCell(0).innerHTML="";//"<td align=\"right\": style=\"border-left-style: none; border-left-width: medium; border-top-style: none; border-top-width: medium;\">处罚依据:</td> ";
row.insertCell(1).innerHTML="<td style=\"border-left-style: none; border-left-width: medium; border-top-style: none; border-top-width: medium;\" colspan=\"3\"><input style=\"width:420px\" id=\"St"+count+"\" type=\"text\" name=\"St"+count+"\"> </td>";//<input type=\"button\" class=\"button\" value=\"删除\" οnclick=\'deleteitem(this);\'>
count ++;
}
}
//function deleteitem(obj)
//{
// var curRow = obj.parentNode.parentNode;
// tb.deleteRow(curRow.rowIndex);
//}
function getsub()
{
var re="";
for (var i = 0 ;i<count;i++)
{
re += document.getElementsByName("St"+i)[0].value+"</br>";
}
document.getElementById("Hidvalue").value=re;
//document.getElementById("Hidhtml").value = document.getElementById("tb").innerHTML;
}
</script>
动态生成位置的table
<table id="tb" border="1" width="100%" bordercolor="#000033" >
<tr>
<td align="right" width="120px" style=" border:none;">
处罚依据:</td>
<td colspan="3" style=" border-left-style: none; border-left-width: medium; border-top-style: none; border-top-width: medium;">
<asp:TextBox ID="Txt_cfyj" runat="server" MaxLength="50" Width="65%"></asp:TextBox>
<a style="color: Red;">*</a><asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="Txt_cfyj" ErrorMessage=""></asp:RequiredFieldValidator>
<input class="button" name="button" οnclick='additem("tb")' type="button" value="添加" />
</td>
</tr>
</table>
使用的部分:string aa = Request.Form["Hidvalue"];