<!--#include file="inc/conn.asp"-->
<!--#include file="inc/function.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="30"></td>';
str += '<td><input type="text" name="Field2" size="30"></td></tr></TBody></Table>';
if (document.all.mytable.rows.length>25){
alert("亲,步骤用的也太多了吧");
}
if (document.all.mytable.rows.length<26)
{
document.all.mytable.outerHTML = str;
}
return false;
}
function deleterow(){
if (document.all.mytable.rows.length>2){
document.all.mytable.deleteRow(document.all.mytable.rows.length-1);
i--;
}
}
</script>
</script>
<form method="POST" action="444.asp?action=do">
<table id=mytable>
<tr>
<td align="center">步骤</td>
<td align="center">说明</td>
</tr>
<tr>
<td><input type="text" name="Field1" size="30"></td>
<td><input type="text" name="Field2" size="30"></td>
</tr>
</table>
<input type=button value="添加用料" name="Cont" οnclick=addrow()>
<input type="button" value="删除" οnclick="deleterow()" />
<input type="submit" value="提交" name="Go">
<%
dim data1,arr1,n1,data2,arr2,n2
data1=Trim(Request.Form("Field1"))
data2=Trim(Request.Form("Field2"))
arr1=split(data1,",")
arr2=split(data2,",")'用Split函数对数据进行分割,测试输出!
for n1= 0 to ubound(arr1)
Response.Write"<input name='Field1"&(n1)&"' value='"&arr1(n1)&"'>"&(n1)&""
Response.Write("<br>")
Next
for n2= 0 to ubound(arr2)
Response.Write"<input name='Field1"&(n2)&"' value='"&arr2(n2)&"'>"&(n2)&""
Response.Write("<br>")
Next
%>
</form>
<%if request("action")="do" then%>
<%
Set lr_sp = Server.CreateObject("ADODB.Recordset")
if ubound(arr1)=0 then
lr_sp="insert into dongtai_test (buzhou1,shuoming1) values('"&arr1(0)&"','"&arr2(0)&"')"
end if
if ubound(arr1)=1 then
lr_sp="insert into dongtai_test (buzhou1,shuoming1,buzhou2,shuoming2) values('"&arr1(0)&"','"&arr2(0)&"','"&arr1(1)&"','"&arr2(1)&"')"
end if
conn.execute(lr_sp)
response.redirect "index.asp"
response.end
%>
<%
end if
%>
</body>
上面是一个动态添加文本框,想根据添加内容,保存到数据库相应的字段里,比如数据库里有buzhou1至buzhou20 , shuoming1至shuoming20,现在只能像上面根据ubound(arr1) 的值一个一个判断,然后保存到对应的字段里,
请问各位能不能根据ubound(arr1) 的值,自动匹配数据库的字段,然后写入数据库,比如当ubound(arr1)=5时,代表buzhou1到buzhou6,shuoming1到shuoming6字段都有数据录入,谢谢各位
<!--#include file="inc/function.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="30"></td>';
str += '<td><input type="text" name="Field2" size="30"></td></tr></TBody></Table>';
if (document.all.mytable.rows.length>25){
alert("亲,步骤用的也太多了吧");
}
if (document.all.mytable.rows.length<26)
{
document.all.mytable.outerHTML = str;
}
return false;
}
function deleterow(){
if (document.all.mytable.rows.length>2){
document.all.mytable.deleteRow(document.all.mytable.rows.length-1);
i--;
}
}
</script>
</script>
<form method="POST" action="444.asp?action=do">
<table id=mytable>
<tr>
<td align="center">步骤</td>
<td align="center">说明</td>
</tr>
<tr>
<td><input type="text" name="Field1" size="30"></td>
<td><input type="text" name="Field2" size="30"></td>
</tr>
</table>
<input type=button value="添加用料" name="Cont" οnclick=addrow()>
<input type="button" value="删除" οnclick="deleterow()" />
<input type="submit" value="提交" name="Go">
<%
dim data1,arr1,n1,data2,arr2,n2
data1=Trim(Request.Form("Field1"))
data2=Trim(Request.Form("Field2"))
arr1=split(data1,",")
arr2=split(data2,",")'用Split函数对数据进行分割,测试输出!
for n1= 0 to ubound(arr1)
Response.Write"<input name='Field1"&(n1)&"' value='"&arr1(n1)&"'>"&(n1)&""
Response.Write("<br>")
Next
for n2= 0 to ubound(arr2)
Response.Write"<input name='Field1"&(n2)&"' value='"&arr2(n2)&"'>"&(n2)&""
Response.Write("<br>")
Next
%>
</form>
<%if request("action")="do" then%>
<%
Set lr_sp = Server.CreateObject("ADODB.Recordset")
if ubound(arr1)=0 then
lr_sp="insert into dongtai_test (buzhou1,shuoming1) values('"&arr1(0)&"','"&arr2(0)&"')"
end if
if ubound(arr1)=1 then
lr_sp="insert into dongtai_test (buzhou1,shuoming1,buzhou2,shuoming2) values('"&arr1(0)&"','"&arr2(0)&"','"&arr1(1)&"','"&arr2(1)&"')"
end if
conn.execute(lr_sp)
response.redirect "index.asp"
response.end
%>
<%
end if
%>
</body>
上面是一个动态添加文本框,想根据添加内容,保存到数据库相应的字段里,比如数据库里有buzhou1至buzhou20 , shuoming1至shuoming20,现在只能像上面根据ubound(arr1) 的值一个一个判断,然后保存到对应的字段里,
请问各位能不能根据ubound(arr1) 的值,自动匹配数据库的字段,然后写入数据库,比如当ubound(arr1)=5时,代表buzhou1到buzhou6,shuoming1到shuoming6字段都有数据录入,谢谢各位