写了一个购物网站 遇到一个问题 就是怎么勾选前面复选框的时候 自动获取价格并相加到总金额哪里
<section class="wrap" style="margin-top:20px;overflow:hidden;">
<c:if test="${sessionScope.lsgDshop != null}">
<div style="text-align: center; color: red; font-size: 20px" class="alert alert-info" role="alert">
<c:out value="${sessionScope.lsgDshop}"/>
<c:remove var="lsgDshop" scope="session"/>
</div>
</c:if>
<c:remove var="session" scope="session"/>
<table class="order_table">
<tr>
<th>#</th>
<th>产品</th>
<th>名称</th>
<th>单价</th>
<th>小计</th>
<th>操作</th>
</tr>
<c:forEach var="cart" items="${showCart}">
<tr>
<td class="center"><input type="checkbox"/></td>
<td class="center"><a href="<c:url value="/checkShowLook?id=${cart.id}"/>"><img src="<c:url value="${cart.photo}"/>" style="width:50px;height:50px;"/></a></td>
<td><a href="<c:url value="/checkShowLook?id=${cart.id}"/>"><c:out value="${cart.name}"/></a></td>
<td class="center"><span class="rmb_icon"><c:out value="${cart.price}"/></span></td>
<td class="center"><strong class="rmb_icon"><c:out value="${cart.price}"/></strong></td>
<td class="center"><a href="<c:url value="/DeleteShop?id=${cart.id}"/>" onclick="return confirm('将要删除商品 ${cart.name},是否继续?')">删除</a></td>
</tr>
</c:forEach>
</table>
<div class="order_btm_btn">
<a href="<c:url value="/orderConfirm"/>" class="link_btn_02 add_btn"/>共计金额<strong class="rmb_icon">0.00</strong>立即结算</a>
</div>
</section>
给tr 绑上id 点击的时候获取指定tr中的第几个td中的值
这个你需要用到js,可以用js监听复选框,但选择的时候,自动加上去即可。
有任何疑问,欢迎前来交流。