java—在表中添加一列以获得总价

ybzsozfc  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(327)

我正在使用上一页的数据来填充购物车中的表,我想知道如何将每个商品的成本x数量相加,以获得添加到购物车中的所有商品的总成本。我使用的代码如下:

  1. <table class="w3-table w3-striped w3-border">
  2. <tr>
  3. <th>Quantity</th>
  4. <th>Name - Description</th>
  5. <th>Price</th>
  6. <th>Amount</th> </tr>
  7. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><c:forEach var="item" items="${cart.items}"><tr>
  8. <td>
  9. form action="" method="post">
  10. <input type="hidden" name="productCode" value="${item.product.id}">
  11. <input type=text name="quantity" value="${item.quantity}" id="quantity">
  12. <input type="submit" value="Update">
  13. </form>
  14. </td>
  15. <td>${item.product.getProductDescription()}</td>
  16. <td>${item.product.getProductPrice()}</td>
  17. <td>${item.totalCurrencyFormat}</td>
  18. <td>
  19. <form action="" method="post">
  20. <input type="hidden" name="productCode"
  21. value="${item.product.id}">
  22. <input type="hidden" name="quantity"
  23. value="0">
  24. <input type="submit" value="Remove Item">
  25. </form>
  26. </td>
  27. </td> </tr></c:forEach></table></div>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题