ASP批量更新有些值为空怎么办?

来源:百度知道 编辑:UC知道 时间:2024/05/23 04:48:49
<%do while not rs.eof%>
<input name="amount" type="text" id="amount" />
<input type="hidden" name="identity" id="identity" value="<%=rs("identity")%>">
<%rs.movenext
loop%>

这样表单提交的话会得到request("amount")和request("identity"),都是一个数组,如request("amount")为1,2,3,4 request("identity")为22,31,88,99等。但是amount是个文本框中,是要自己填的,如果不填的话值为空,就会变成1,2,3,4和22,88,99了,金额就不能对应ID进行数据库的更新了。
要求:1,不要将amount文本框初始值设为0。
2,不进行javascript对所填值不得为空的检验,如果访客填的是空值,将其转换为0存入数据库。

For i = 1 To Request.Form("amount").Count
if Trim(Request.Form("amount")(i))<>"" then
amount = amount & "," & Trim(Request.Form("amount")(i))
else
amount = amount & "," & 0
end if
Next

For i = 1 To Request.Form("identity").Count
if Trim(Request.Form("identity")(i))<>"" then
identity = identity & "," & Trim(Request.Form("identity")(i))
else
identity = identity & "," & 0
end if
Next

'输出结果看是否符合要求
response.write "amount=>" & amount

response.write "identity=>" & identity
然后随便怎么操作吧,不过实际上还要验证用户输入的是否是数字