agjs

<i><%@page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">


<title>My JSP 'Goods.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="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
<script
src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/angularjs.js"></script>
<script type="text/javascript" src="js/jquery-2.1.0.js"></script>
<script type="text/javascript">
var app = angular.module("myapp", []);
//进来就查询所有商品
app.controller("myController", function($scope, $http) {
$http.post("GoodsController/findGoods").success(function(obj) {


$scope.product = obj;
});
//点击加的按钮减1
$scope.jia = function(index) {
var id = $scope.product[index].id;


$http.post("GoodsController/jia?id=" + id).success(

++$scope.product[index].account);
};
//点击减的按钮减1
$scope.jian = function(index) {
var id = $scope.product[index].id;
var account = $scope.product[index].account;
if (account > 1) {


$http.post("GoodsController/jian?id=" + id).success(
--$scope.product[index].account);
} else {


if (confirm("确认删除?")) {
$http.post("GoodsController/Del?id=" + id).success(
function() {
alert("删除成功");
location.reload();
});
}


}


};


//点击删除的按钮删除
$scope.del = function(index) {
var id = $scope.product[index].id;


if (confirm("确认删除?")) {
$http.post("GoodsController/Del?id=" + id).success(function() {
alert("删除成功");
location.reload();
});
}
};


$scope.update = function(index) {
var id = $scope.product[index].id;
var account = $scope.product[index].account;
alert(id);
alert(account);
$http.post("GoodsController/updateGoods?id=" + id + "&account="
+ account);
};


});


function sub() {
var arr = [];
var uid = ${nameid}


$(":checked").each(function() {


arr.push($(this).val());
});
alert(arr.length);


if (arr.length < 1) {
alert("请至少选中一件物品!");
return false;
} else {
$.post("OrderController/addOrder", {
"gid" : arr.join(","),
"uid" : uid
}, function(da) {


if (da == "ok") {
alert("发送成功!");
} else {
alert("发送失败!");
}
}, "json");
}


}
</script>






</head>


<body ng-app="myapp">
<div class="container" ng-controller="myController">
<h1>欢迎进入购物车</h1>


<table>
<tr>
<td><input type="checkbox" ng-model="all"></td>
<td>商品编号</td>
<td>商品名称</td>
<td>商品价格</td>
<td>购买数量</td>
<td>操作</td>


</tr>


<tr ng-repeat="p in product">
<td><input type="checkbox" value="{{p.id}}" ng-checked="all"
value="{{p.id}}" class="fxk"></td>
<td>{{p.id}}</td>
<td>{{p.goodsname}}</td>
<td>{{p.price}}</td>


<td>
<button class=" btn btn-success" value="{{p.id}}"
ng-click="jia($index)">+</button>
<input type="text"
ng-model="p.account" style="width: 30" value="{{p.account}}"
ng-blur="update($index)" class="account">


<button class="btn btn-success" value="{{p.id}}"
ng-click="jian($index)">-</button>
</td>
<td><button class=" btn " ng-click="del($index)">删除</button></td>


</tr>


<tr>
<td><button class=" btn btn-success" οnclick="sub()">购买</button></td>


</tr>


</table>


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值