我正在使用上一页的数据来填充购物车中的表,我想知道如何将每个商品的成本x数量相加,以获得添加到购物车中的所有商品的总成本。我使用的代码如下:
<table class="w3-table w3-striped w3-border">
<tr>
<th>Quantity</th>
<th>Name - Description</th>
<th>Price</th>
<th>Amount</th> </tr>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><c:forEach var="item" items="${cart.items}"><tr>
<td>
form action="" method="post">
<input type="hidden" name="productCode" value="${item.product.id}">
<input type=text name="quantity" value="${item.quantity}" id="quantity">
<input type="submit" value="Update">
</form>
</td>
<td>${item.product.getProductDescription()}</td>
<td>${item.product.getProductPrice()}</td>
<td>${item.totalCurrencyFormat}</td>
<td>
<form action="" method="post">
<input type="hidden" name="productCode"
value="${item.product.id}">
<input type="hidden" name="quantity"
value="0">
<input type="submit" value="Remove Item">
</form>
</td>
</td> </tr></c:forEach></table></div>
暂无答案!
目前还没有任何答案,快来回答吧!