一个很奇怪的问题

ccccffff 2003-09-29 12:30:23
内容如下:
购物车列举信息:
<table bgcolor="lemon" width="70%" align="center" border="0">
<tr bgcolor="#fcd758">
<td>商品序号</td>
<td>商品名称</td>
<td>商品价格</td>
<td>商品数量</td>
<td>商品总值</td>
<td>定购时间</td>
<td>移出商品</td>
</tr>
<%
int posion=(showPage-1)*pageSize+1;
rs.absolute(posion);
for(int i=1;i<=pageSize;i++)
{
String id=rs.getString("id");
String name=rs.getString("name");
String price=rs.getString("price");
String amount=rs.getString("amount");
String total=rs.getString("total");
String time=rs.getString("time");
float tmp_price=Float.parseFloat(price);
float tmp_total=Float.parseFloat(total);

%>
<tr bgcolor="#d9f499">
<td><%=id%></td>
<td><%=name%></td>
<td><%=tmp_price%></td>
<td><%=amount%></td>
<td><%=tmp_total%></td>
<td><%=time%></td>
<td><input type="checkbox" name="ProductID" value=<%=id%>></td>
</tr>
<%
rs.next();

}

%>
</table>
<% }
删除选中商品
<form action="" method="post">
<table align="center" width="70%">
<tr bgcolor="#6666FF">
<td><center>
<input type="submit" name="Submit" value="确定移出">   
</center></td>
</tr>
</table>
</form>
<!---------------------------- 删除选中物品 ----------------------------------->
<%
String buttonId=request.getParameter("ProductID");
if(buttonId != null && buttonId.length() != 0)
{
try
{
workM.executeQuery("DELETE FROM orderform WHERE id="+"'"+buttonId+"'");

}
catch(Exception e){}
}
%>

怎么就删除不了呢?程序应该没问题阿
...全文
27 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwwevil 2003-09-29
  • 打赏
  • 举报
回复
程序是有问题的
<%
//String buttonId=request.getParameter("ProductID");//这里只能得到一个值
String [] buttonId = request.getParameterValues("ProductID"); //这样可以得到传过来的所有值

if(buttonId != null && buttonId.length() != 0)
{
for( int i = 0; i < buttonId.length; i ++ ) {
try
{
workM.executeQuery("DELETE FROM orderform WHERE id="+"'"+buttonId[i]+"'");

}
catch(Exception e){}
}
}
%>
还有一个问题:客户端把所有的checkbox都传了过来,我想应该在客户端用javascript处理一下,把选中的传过来,没有选中的,就不要传递
aku0708 2003-09-29
  • 打赏
  • 举报
回复
你断点跟一下,看有没有获到值,
我看你的程序没有什么问题,是一个都不能删除,还是有的能删除,有的不能删除呢
flashroom 2003-09-29
  • 打赏
  • 举报
回复
<input type="checkbox" name="ProductID" value=<%=id%>>

---》

<input type="radio" name="ProductID" value=<%=id%>>

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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