
ASP编程如何将同一数据库多条记录显示,并可同时修改(只需设置一键提交全部修改,不需逐条保存)
ASP编程如何将同一数据库多条记录显示,同时可以修改,修改时只需设置一“提交修改”按钮,即可提交所有修改记录,无需逐条保存这么麻烦谢谢大家的帮手...
ASP编程
如何将同一数据库多条记录显示,
同时可以修改,
修改时只需设置一“提交修改”按钮,即可提交所有修改记录,
无需逐条保存这么麻烦
谢谢大家的帮手 展开
如何将同一数据库多条记录显示,
同时可以修改,
修改时只需设置一“提交修改”按钮,即可提交所有修改记录,
无需逐条保存这么麻烦
谢谢大家的帮手 展开
2个回答
2013-07-24
展开全部
我给你个我今天编写的程序吧
你看了自己照着改就可以了<%id=request("id")
xztype=trim(request("xztype"))
if id<>"" and xztype<>"" then
id=int(id)
%>
<table width="100%" border="1" align="center" bordercolor="cccccc">
<form action="bxfl2save.asp" method="post">
<tr align="center" bgcolor="#CCCCCC">
<td height="27">性别</td>
<td>年龄</td>
<td>保险金额</td>
<td>缴费期限<input type="hidden" name="idd" value="<%=id%>">
<input type="hidden" name="xztype" value="<%=xztype%>"></td><td>保费</td>
</tr>
<%sql="select * from bftable where xztype='"&xztype&"' and idd="&id
rs.open sql,conn,1,3
if rs.recordcount=0 then
rs.close
response.write"<tr><td colspan=5><a href=bxfl.asp>请先添加保费后再修改保费</a></td></tr>"
response.end
else
soon=rs.recordcount
do while not rs.eof
i=i+1
if i=2 then
i=0
end if
if i=1 then
xx=""
end if
if i=0 then
xx="bgcolor=#cccccc"
end if
%>
<tr align="center" <%=xx%> >
<td height="27"><input name=id type="hidden" value="<%=rs("id")%>"><select name="sex" size="1" id="sex">
<option value="男" <%if trim(rs("sex"))="男" then
response.write " selected "
end if%>>男</option>
<option value="女" <%if trim(rs("sex"))="女" then
response.write " selected "
end if%>>女</option>
</select>
</td>
<td><input name="age" id="age" size="15" value="<%=trim(rs("age"))%>"></td>
<td><input name="bxmoney" id="bxmoney" size="15" value="<%=trim(rs("bxmoney"))%>"></td>
<td><input name="jfterm" id="jfterm" size="15" value="<%=trim(rs("jfterm"))%>"></td>
<td><input name="bf" size="15" value="<%=trim(rs("bf"))%>"></td>
</tr>
<%rs.movenext
loop
soon=i+1
if (soon mod 2)=0 then
xx="bgcolor=#cccccc"
else
xx=""
end if
end if
response.write"<tr "&xx&"><td colspan=5 height=27 align=center><input type=submit name=Submit value=确定 /></td></tr>"
%></form>
</table>
<%else
end if%>
上面是显示多条记录
下面是修改多条记录
<%
id=request("id")
idd=request("idd")
xztype=request("xztype")
sex=request("sex")
age=request("age")
bxmoney=request("bxmoney")
jfterm=request("jfterm")
bf=request("bf")
sex=split(sex,",")
for i = 0 to ubound(sex)
sex(i)=sex(i)
next
age=split(age,",")
for i = 0 to ubound(age)
age(i)=age(i)
next
bxmoney=split(bxmoney,",")
for i = 0 to ubound(bxmoney)
bxmoney(i)=bxmoney(i)
next
jfterm=split(jfterm,",")
for i = 0 to ubound(jfterm)
jfterm(i)=jfterm(i)
next
bf=split(bf,",")
for i = 0 to ubound(bf)
bf(i)=bf(i)
next
id=split(id,",")
for i = 0 to ubound(id)
id(i)=id(i)
next
for i=0 to ubound(bf)
if sex(i)<>"" or age(i)<>"" or bxmoney(i)<>"" or jfterm(i)<>"" or bf(i)<>"" then
sql="select * from bftable where id="&trim(id(i))
rs.open sql,conn,1,3
rs("sex")=trim(sex(i))
rs("age")=trim(age(i))
rs("bxmoney")=trim(bxmoney(i))
rs("jfterm")=trim(jfterm(i))
rs("bf")=trim(bf(i))
rs.update
rs.close
end if
next
%>
你看了自己照着改就可以了<%id=request("id")
xztype=trim(request("xztype"))
if id<>"" and xztype<>"" then
id=int(id)
%>
<table width="100%" border="1" align="center" bordercolor="cccccc">
<form action="bxfl2save.asp" method="post">
<tr align="center" bgcolor="#CCCCCC">
<td height="27">性别</td>
<td>年龄</td>
<td>保险金额</td>
<td>缴费期限<input type="hidden" name="idd" value="<%=id%>">
<input type="hidden" name="xztype" value="<%=xztype%>"></td><td>保费</td>
</tr>
<%sql="select * from bftable where xztype='"&xztype&"' and idd="&id
rs.open sql,conn,1,3
if rs.recordcount=0 then
rs.close
response.write"<tr><td colspan=5><a href=bxfl.asp>请先添加保费后再修改保费</a></td></tr>"
response.end
else
soon=rs.recordcount
do while not rs.eof
i=i+1
if i=2 then
i=0
end if
if i=1 then
xx=""
end if
if i=0 then
xx="bgcolor=#cccccc"
end if
%>
<tr align="center" <%=xx%> >
<td height="27"><input name=id type="hidden" value="<%=rs("id")%>"><select name="sex" size="1" id="sex">
<option value="男" <%if trim(rs("sex"))="男" then
response.write " selected "
end if%>>男</option>
<option value="女" <%if trim(rs("sex"))="女" then
response.write " selected "
end if%>>女</option>
</select>
</td>
<td><input name="age" id="age" size="15" value="<%=trim(rs("age"))%>"></td>
<td><input name="bxmoney" id="bxmoney" size="15" value="<%=trim(rs("bxmoney"))%>"></td>
<td><input name="jfterm" id="jfterm" size="15" value="<%=trim(rs("jfterm"))%>"></td>
<td><input name="bf" size="15" value="<%=trim(rs("bf"))%>"></td>
</tr>
<%rs.movenext
loop
soon=i+1
if (soon mod 2)=0 then
xx="bgcolor=#cccccc"
else
xx=""
end if
end if
response.write"<tr "&xx&"><td colspan=5 height=27 align=center><input type=submit name=Submit value=确定 /></td></tr>"
%></form>
</table>
<%else
end if%>
上面是显示多条记录
下面是修改多条记录
<%
id=request("id")
idd=request("idd")
xztype=request("xztype")
sex=request("sex")
age=request("age")
bxmoney=request("bxmoney")
jfterm=request("jfterm")
bf=request("bf")
sex=split(sex,",")
for i = 0 to ubound(sex)
sex(i)=sex(i)
next
age=split(age,",")
for i = 0 to ubound(age)
age(i)=age(i)
next
bxmoney=split(bxmoney,",")
for i = 0 to ubound(bxmoney)
bxmoney(i)=bxmoney(i)
next
jfterm=split(jfterm,",")
for i = 0 to ubound(jfterm)
jfterm(i)=jfterm(i)
next
bf=split(bf,",")
for i = 0 to ubound(bf)
bf(i)=bf(i)
next
id=split(id,",")
for i = 0 to ubound(id)
id(i)=id(i)
next
for i=0 to ubound(bf)
if sex(i)<>"" or age(i)<>"" or bxmoney(i)<>"" or jfterm(i)<>"" or bf(i)<>"" then
sql="select * from bftable where id="&trim(id(i))
rs.open sql,conn,1,3
rs("sex")=trim(sex(i))
rs("age")=trim(age(i))
rs("bxmoney")=trim(bxmoney(i))
rs("jfterm")=trim(jfterm(i))
rs("bf")=trim(bf(i))
rs.update
rs.close
end if
next
%>
2013-07-24
展开全部
记录
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询