%@ taglib prefix="c" uri="
%@ taglib uri="
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
html xmlns="
head
meta http-equiv="Content-Type" content="text/html; charset=utf-8" /
title易买网 - 首页/title
link type="text/css" rel="stylesheet" href="https://www.04ip.com/post/${pageContext.request.contextPath }/css/style.css" /
script type="text/javascript" src="/images/defaultpic.gif"/script
script type="text/javascript"
var contextPath = '${pageContext.request.contextPath }';
/script
script type="text/javascript" src="/images/defaultpic.gif"/script
/head
body
jsp:include page="top.jsp" /
div id="position" class="wrap"
您现在java简易购物车源代码的位置:a href="https://www.04ip.com/post/Home"易买网/a gt; 购物车
/div
div class="wrap"
div id="shopping"
form action="" method="post"
table
tr
th商品名称/th
th商品价格/th
th购买数量/th
th操作/th
/tr
c:forEach items="${sessionScope.shopCar}"var="item" varStatus="status"
tr id="product_id_${item.proId}"
td class="thumb"img src="/images/defaultpic.gif"${item.proName}/a/td
td class="price" id="price_id_1"
spanfmt:formatNumber value="https://www.04ip.com/post/${item.proPrice}" type="NUMBER" minFractionDigits="2" //span
input type="hidden" value="https://www.04ip.com/post/${item.proPrice}" /
/td
td class="number"
dl
dtspan onclick="sub('number_id_${item.proId}','${item.proId}')"-/spaninput id="number_id_${item.proId}" type="text" readonly="readonly" name="number" value="https://www.04ip.com/post/${item.proNum}" /span onclick="addNum('number_id_${item.proId}','${item.proId}')"+/span/dt
/dl
/td
td class="delete"a href="javascript:deleteItem('product_id_${item.proId}','${item.proId}')"删除/a/td
/tr
/c:forEach
/table
div class="button"input type="submit" value="" //div
/form
/div
/div
div id="footer"
Copyright copy;kaka292817678 itjob远标培训.
/div
/body
/html
页面关联java简易购物车源代码的js 自己去网上下载一个jquery
/*数量减少*/
function sub(id,proId){
//购买数量java简易购物车源代码的值
var num = $('#'+id).val();
if(num1){
$('#'+id).val(num - 1);
}
edit(id,proId);
}
function edit(id,proId){
var url = contextPath + '/HomeCarManager';
//修改后的数量,购物明细的商品的id
num = $('#'+id).val();
$.post(url,{"num":num,"proId":proId},function (msg){
/*
if(msg == 'true'){
alert('修改成功');
} else {
alert('修改失败');
}*/
});
}
/**
* 数量增加
* @param {} id
*/
function addNum(id,proId){
//购买数量的值
var num = $('#'+id).val();
$('#'+id).val(parseInt(num) + 1);
edit(id,proId);
}
/**
* 删除购物明细
*/
function deleteItem(trId,proId){
//
//console.log($("#"+trId));
//js删除页面节点
//$("#"+trId).remove();
var url = contextPath + '/HomeCarManager';
$.post(url,{"proId":proId},function (msg){
if(msg == 'true'){
//js删除页面节点
$("#"+trId).remove();
}
});
}
后台servlet1
package com.kaka.web;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
推荐阅读
- 直播伴侣变老人,直播伴侣使用说明
- 直播关注什么意思,直播里面的关注是什么意思
- 纸牌游戏单机版,纸牌游戏合集 安卓
- 配音设备推荐直播,直播配音软件app排行
- linux并行执行命令 linux并发执行命令的方式
- 包含h5jquerybootstrap的词条
- 华为手机怎么查看当前温度,华为手机在哪里可以看到手机温度
- linux命令括号 linux命令括号怎么打
- 怎么制作win7u盘启动盘,怎样制作windows7启动盘