Buy.jsp

//修改购物车商品的数量
    if (action != null && action.equals("update")) {
        Iterator<CartItem> it = c.getItems().iterator();
        while (it.hasNext()) {
            CartItem item = it.next();
            int count = Integer.parseInt(request.getParameter("p"
                    + item.getProduct().getPid()));
            item.setCount(count);
        }
    }


<form action="Buy.jsp" method="get">
            <input type="hidden" name="action" value="update" />
...
<td>
                        <input type="text" name="<%="p" + ci.getProduct().getPid()%>"
                            value="<%=ci.getCount()%>" size="3" /><!--每个购物项的数量文本框-->
</td>

...
<td colspan="7">
                        <a href="Confirm.jsp">下单</a>&nbsp;
                        <a href="javascript:document.forms[0].submit()">修改</a>
                    </td><!--采用链接的方式提交表单-->

 

相关文章:

  • 2021-05-24
  • 2021-11-23
  • 2021-05-17
  • 2022-12-23
  • 2021-06-24
猜你喜欢
  • 2022-12-23
  • 2021-04-07
  • 2021-07-01
  • 2021-12-04
  • 2021-08-31
  • 2021-12-20
  • 2021-08-12
相关资源
相似解决方案