shoppingcart基础页面

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    
    -->
<link rel="stylesheet" href="css/bootstrap.css" />
<script type="text/javascript"
    src="${pageContext.request.contextPath}/js/jquery-1.8.3.js"></script>
<script type="application/javascript"
    src="${pageContext.request.contextPath}/js/angularjs.js"></script>
<script>
               /*控制区 */
    angular.module('myapp', [])
    .controller(
            'controller',
            function($scope, $http) {
                $http.get("${pageContext.request.contextPath}/shop/all")
                        .success(function(a) {
                            $scope.cart = a;

                        });
                        /* 减按钮 */
                 $scope.reduce=function(index)
                 {
                 $scope.cart[index].count= $scope.cart[index].count-1;
                     var ssid= $scope.cart[index].ssid;
                 var count=  $scope.cart[index].count;
                 $.post("${pageContext.request.contextPath}/shop/update",{"ssid":ssid,"count":count});
                 
                 };
                 
                     /* 加按钮 */
                  $scope.add=function(index)
                 {
                 $scope.cart[index].count= $scope.cart[index].count+1;
                     var ssid= $scope.cart[index].ssid;
                 var count=  $scope.cart[index].count;
                 $.post("${pageContext.request.contextPath}/shop/update",{"ssid":ssid,"count":count});
                 
                 }
                  /* 全选按钮 */
                $("#all").click(function(){                
                  $("input[type='checkbox']:gt(0)").prop("checked",$(this).prop("checked"));
                })
                var array=new Array();
                 /* 批量删除 */
                $("#delete").click(function(){
                    
                    $("input[type='checkbox']:gt(0):checked").each(function(){                    
                     array.push($(this).val());        
                                
                    });
                 $.post("${pageContext.request.contextPath}/shop/delete?array="+array+"",function(a)
                 {
                   location.reload();
                 
                 });
              });
            });
</script>
</head>

<body ng-app="myapp">
<div class="row" ng-controller="controller">
 <div class="col-md-1 col-md-offset-9">
 <button class="btn btn-danger" id="delete">批量删除</button>
 
 </div>
<div class="col-md-7 col-md-offset-3">
   
     <table class="table nth-child table-bordered table-hover table-condensed">
     <thead>
     <tr>
     <td><input type="checkbox" id="all"></td>
      <td>用户名</td>
      <td>商品名</td>
      <td>单价</td>
      <td>数量</td>
      <td>小计</td>
     </tr>
     </thead>
     <tbody>
     <tr ng-repeat="x in cart">
        <td><input type="checkbox"  value="{{x.ssid}}"></td>
        <td>{{x.tuser.uname}}</td>
           <td>{{x.tproduct.name}}</td>
              <td>{{x.tproduct.price | number:2 | currency:"¥ "}}</td>
                 <td>
                 <button ng-click="reduce($index)">-</button>
                 <input value="{{x.count}}" style="width: 30px">
                  <button  ng-click="add($index)" >+</button>
                 </td>
                    <td>{{x.tproduct.price *x.count | number:2 | currency:"¥ " }}</td>
     </tr>
     </tbody>
     </table>

</div>
</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值