标签:
一。全反选cart-1.html中写script语句
function checkAll(obj, name) { var el = document.getElementsByTagName(‘input‘); var len = el.length; for (var key in el) { if (el[key].name == name) { if(obj.checked == true) { el[key].checked = true; } else { el[key].checked = false; } } }
全选按钮加onclick
<th class="wp7_5"><input type="checkbox" onclick="checkAll(this,‘checkTest‘)" class="vm" /> 全选</th>
二。增加减少按钮,cart-1.html中遍历多个增加减少按钮
<div class="chooseAmount"> <a href="javascript:void(0);" th:onclick="${#strings.concat(‘subNum(‘).concat(cartsInfo.commodityId).concat(‘)‘)}"></a> <input th:id="${cartsInfo.commodityId}" type="text" class="fl inp-t" value="1" /> <a href="javascript:void(0);" th:onclick="${#strings.concat(‘addNum(‘).concat(cartsInfo.commodityId).concat(‘)‘)}"></a> </div>
三。each循环语句从数据库中列出购物车的多件商品信息
<tbody th:each="cartsInfo,status:${cartList}">//循环语句 <tr><td class="chk"><input type="checkbox" name="checkTest" /></td> <td><div class="cont cf"><img th:src="@{showImage(pictureId=${cartsInfo.pictureId})}" class="pic" /> <h4><span th:text="${cartsInfo.commodityName}"></span></h4> <p class=" mt10">规格:每<span th:text="${#strings.concat(cartsInfo.unit).concat(cartsInfo.specifications)}"></span></p> <p>品牌:<span th:text="${cartsInfo.brandName}"></span></p> </div></td> <td><p class="price yh"><span th:text="${cartsInfo.retailPrice}"></span>元</p></td>//商品信息 <td><div class="chooseAmount"><a href="javascript:void(0);" th:onclick="${#strings.concat(‘subNum(‘).concat(cartsInfo.commodityId).concat(‘)‘)}"></a> <input th:id="${cartsInfo.commodityId}" type="text" class="fl inp-t" value="1" /> <a href="javascript:void(0);" th:onclick="${#strings.concat(‘addNum(‘).concat(cartsInfo.commodityId).concat(‘)‘)}"></a></div></td>//增加减少按钮 <td><p class="price yh"><span th:text="${cartsInfo.retailPrice}"></span>元</p></td> <td><a class="button" th:href="@{delCart(cartId=${cartsInfo.cartId},count=${cartsInfo.count},commodityId=${cartsInfo.commodityId})}"><span>删除</span></a></td></tr> </tbody>
标签:
原文地址:http://my.oschina.net/u/2411776/blog/488249