关于array数组修改问题!

hgxlucky 2008-07-03 11:35:23
共有6种物品,我想把保存起来的数据修改,我不知道怎么表示,我的本意是客人选择了哪种物品,修改的时候就是客人选择的物品,我是这样写的,不知问题在哪里,显示不正常!

<%
aa= split(rs2("credit1"),",")
for i=0 to Ubound(aa)
%>

<% if aa(i)=1 then %>
<input type="checkbox" name="credit1" value="1" checked> 物品1
<%else%>
<input type="checkbox" name="credit1" value="1"> 物品1
<% end if %>

<% if aa(i)=2 then %>
<input type="checkbox" name="credit1" value="2" checked> 物品2
<%else%>
<input type="checkbox" name="credit1" value="2"> 物品2
<% end if %>

<% if aa(i)=3 then %>
<input type="checkbox" name="credit1" value="3" checked> 物品3<br>
<%else%>
<input type="checkbox" name="credit1" value="3"> 物品3<br>
<% end if %>

<% if aa(i)=4 then %>
<input type="checkbox" name="credit1" value="4" checked> 物品4
<%else%>
<input type="checkbox" name="credit1" value="4"> 物品4
<% end if %>

<% if aa(i)=5 then %>
<input type="checkbox" name="credit1" value="5" checked> 物品5
<%else%>
<input type="checkbox" name="credit1" value="5"> 物品5
<% end if %>

<% if aa(i)=6 then %>
<input type="checkbox" name="credit1" value="6" checked> 物品6<br>
<%else%>
<input type="checkbox" name="credit1" value="6"> 物品6<br>
<% end if %>

<% if aa(i)=0 then %>
<input type="checkbox" name="credit1" value="0" checked> 不需要
<%else%>
<input type="checkbox" name="credit1" value="0"> 不需要
<% end if %>

<%
next
%>
...全文
71 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
hgxlucky 2008-07-03
  • 打赏
  • 举报
回复
谢谢 chinmo ,问题解决了!
  • 打赏
  • 举报
回复
<% 
aa= split(rs2("credit1"),",")
for i=0 to Ubound(aa)
if aa(i)=1 then
checked1="checked"
elseif aa(i)=2 then
checked2="checked"
elseif aa(i)=3 then
checked3="checked"
elseif aa(i)=4 then
checked4="checked"
elseif aa(i)=5 then
checked5="checked"
elseif aa(i)=6 then
checked6="checked"
elseif aa(i)=0 then
checked="checked"
end if

next
%>
<input type="checkbox" name="credit1" value="1" <%=checked1%> > 物品1
<input type="checkbox" name="credit1" value="2" <%=checked2%>> 物品2
<input type="checkbox" name="credit1" value="3" <%=checked3%>> 物品3 <br>
<input type="checkbox" name="credit1" value="4" <%=checked4%>> 物品4
<input type="checkbox" name="credit1" value="5" <%=checked5%>> 物品5
<input type="checkbox" name="credit1" value="6" <%=checked6%>> 物品6 <br>
<input type="checkbox" name="credit1" value="0" <%=checked%>> <% if checked="checked" then %>不 <% end if %> 需要
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 hgxlucky 的回复:]
credit1字段用来存储物品,物品代码分别用1,2,3,4,5,6来表示物品1,物品2,物品3,物品4,物品5,物品6,就是客人选择的数据保存在credit1里面,如果它选择了物品1,物品2,物品5,那么字段credit1里面就保存1,2,5,如过要修改订单,应该怎么办呢?我不知道怎么写!
[/Quote]

按你的意思,你的程序应该这样才对:

<%
aa= split(rs2("credit1"),",")
for i=0 to Ubound(aa)
if aa(i)=1 then
checked1="checked"
elseif aa(i)=2 then
checked2="checked"
elseif aa(i)=3 then
checked3="checked"
elseif aa(i)=4 then
checked4="checked"
elseif aa(i)=5 then
checked5="checked"
elseif aa(i)=6 then
checked6="checked"
elseif aa(i)=0 then
checked="checked"
end if

next
%>
<input type="checkbox" name="credit1" value="1" <%=checked1%> > 物品1
<input type="checkbox" name="credit1" value="2" <%=checked2%>> 物品2
<input type="checkbox" name="credit1" value="3" <%=checked3%>> 物品3 <br>
<input type="checkbox" name="credit1" value="4" <%=checked4%>> 物品4
<input type="checkbox" name="credit1" value="5" <%=checked5%>> 物品5
<input type="checkbox" name="credit1" value="6" <%=checked6%>> 物品6 <br>
<input type="checkbox" name="credit1" value="0" <%=checked%>> <% if checked="checked" then %>不<% end if %> 需要
  • 打赏
  • 举报
回复
 
<%
aa= split(rs2("credit1"),",")
for i=0 to Ubound(aa)
%>
<input type="checkbox" name="credit1" value="1" <% if aa(i)=1 then %> checked<% end if %> > 物品1



<input type="checkbox" name="credit1" value="2" <% if aa(i)=2 then %>checked<% end if %> > 物品2



<input type="checkbox" name="credit1" value="3" <% if aa(i)=3 then %> checked<% end if %> > 物品3 <br>



<input type="checkbox" name="credit1" value="4" <% if aa(i)=4 then %>checked<% end if %> > 物品4




<input type="checkbox" name="credit1" value="5" <% if aa(i)=5 then %> checked<% end if %> > 物品5



<input type="checkbox" name="credit1" value="6" <% if aa(i)=6 then %>checked <% end if %> > 物品6 <br>


<input type="checkbox" name="credit1" value="0" <% if aa(i)=0 then %>checked <% end if %> > <% if aa(i)=0 then %>不<% end if %> 需要

<%
next
%>


你的代码完全可以简化成这样
hgxlucky 2008-07-03
  • 打赏
  • 举报
回复
credit1字段用来存储物品,物品代码分别用1,2,3,4,5,6来表示物品1,物品2,物品3,物品4,物品5,物品6,就是客人选择的数据保存在credit1里面,如果它选择了物品1,物品2,物品5,那么字段credit1里面就保存1,2,5,如过要修改订单,应该怎么办呢?我不知道怎么写!
  • 打赏
  • 举报
回复
而且你没有必要这么写
  • 打赏
  • 举报
回复
说得不够明白
wjazz 2008-07-03
  • 打赏
  • 举报
回复
怎么显示不正常了,还是提示了什么错误?

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧