日期:2014-05-17  浏览次数:20827 次

ASP如何批量上传记录
例如:字段一     字段二          
          文本框       文本框           继续添加


                              提交

当点击继续添加,表格下面就增加一行,意思就是一行一条记录,点提交,就一次性把全部都提交到数据库

------解决方案--------------------
<body>
<!-- 以下是代码 -->
<script>
i=1;
function addrow()
{
i++;
str = document.all.mytable.outerHTML;
str = str.substring(0,str.length-16);
str += ' <tr> <td> <input type= "text " name= "Field1 " size= "20 "> </td> ';
str += ' <td> <input type= "text " name= "Field2 " size= "20 "> </td> </tr> </TBody> </Table> ';
document.all.mytable.outerHTML = str;
}
</script>
<form method= "POST " action= " ">
<table id=mytable>
<tr>
<td align= "center "> 字段一 </td>
<td align= "center "> 字段二 </td>
</tr>
<tr>
<td> <input type= "text " name= "Field1 " size= "20 "> </td>
<td> <input type= "text " name= "Field2 " size= "20 "> </td>
</tr>
</table>
<input type=button value= "继续添加 " name= "Cont " onclick=addrow()>
<input type= "submit " value= "提交 " name= "Go ">
<input type= "reset " value= "全部重写 " name= "Rst ">
</form>

<!-- 以下是测试(提交到本页) -->
<%
Dim FieldIdx, ValueCount

ValueCount = Request.Form( "Field1 ").Count

For FieldIdx = 1 to ValueCount
'没有演示写入数据表的代码, 只是简单地把提交的元素列出如下
Response.Write Request.Form( "Field1 ")(FieldIdx) & " " & Request.Form( "Field2 ")(FieldIdx) & " <p> "
Next
%>
</body>