简易商品购物车

<html><head>
<title>商品购物车</title>
<meta charset="utf-8">
<style type="text/css">
body{
margin:0;
padding:0;
font-size:12px;
line-height:20px;
color:#333;
}
ul,li,ol,h1,dl,dd{
list-style:none;
margin:0;
padding:0;
}
a{
color:#333;
text-decoration: none;
}
a:hover{
color:#333;
text-decoration:underline;
}
img{
border:0;
vertical-align: middle;
}
.blue{
color:#1965b3;
text-decoration:none;
}
.blue:hover{
color:#1965b3;
text-decoration:underline;
}
#header,#main,#footer{
width:960px;
margin:0 auto;
clear:both;
float:none;
margin-bottom: 30px;
}

/*购物车页面样式开始*/
.shopping_commend{
background-repeat:repeat-x;
height:21px;
border:solid 1px #999;
}
.shopping_commend_left{
float:left;
padding-left:10px;
}
.shopping_commend_right{
float:right;
padding-right:10px;
margin-top:3px;
}
.shopping_commend_right img{
cursor:pointer;
}
#shopping_commend_sort{
margin-top: 20px;
padding:5px 20px 5px 20px;
height:120px;
}
.shopping_commend_sort_left{
float:left;
width:450px;
}
.shopping_commend_list_1,.shopping_commend_list_2,.shopping_commend_list_3,.shopping_commend_list_4{
float:left;
height:30px;
line-height:30px;
}
.shopping_commend_list_1{
width:240px;
}
.shopping_commend_list_2{
width:70px;
text-align:center;
text-decoration:line-through;
color:#999;
}
.shopping_commend_list_3{
width:70px;
text-align:center;
}
.shopping_commend_list_4{
text-align:center;
width:65px;
}
.shopping_yellow{
color:#ED610C;
}
.shopping_yellow:hover{
color:#ED610C;
text-decoration:underline;
}
.shopping_list_top{
clear:both;
font-size:14px;
font-weight:bold;
margin-top:20px;
}
.shopping_list_border{
border:solid 2px #999;
}
.shopping_list_title{
background-color:#d8e4c6;
height:25px;
}
.shopping_list_title li{
float:left;
line-height:28px;
}
.shopping_list_title_1{
width:420px;
padding-left:30px;
text-align:left;
}
.shopping_list_title_2{
width:120px;
text-align:center;
}
.shopping_list_title_3{
width:120px;
text-align:center;
}
.shopping_list_title_4{
width:120px;
text-align:center;
}
.shopping_list_title_5{
width:70px;
text-align:center;
}
.shopping_list_title_6{
width:70px;
text-align:center;
}
.shopping_product_list{
background-color:#fefbf2;
height:40px;

}
.shopping_product_list input{
width:30px;
height:15px;
border:solid 1px #666;
text-align:center;
}
.shopping_product_list td{
line-height:35px;
border-bottom:dashed 1px #ccc;
}
.shopping_product_list_1{
width:420px;
padding-left:30px;
text-align:left;
}
.shopping_product_list_2{
width:120px;
text-align:center;
color:#464646;
}
.shopping_product_list_3{
width:120px;
text-align:center;
color:#464646;
}
.shopping_product_list_4{
width:120px;
text-align:center;
color:#191919;
}
.shopping_product_list_5{
width:70px;
text-align:center;
}
.shopping_product_list_6{
width:70px;
text-align:center;
}
.shopping_list_end{
background-color:#cddbb8;
height:60px;
}
.shopping_list_end li{
float:right;
}
.shopping_list_end_1{
margin:10px 10px 0;
}
.shopping_list_end_2{
font-weight:bold;
color:#BD3E00;
font-size:14px;
margin:15px 10px 0px 0px;
}
.shopping_list_end_3{
font-weight:bold;
font-size:14px;
margin:15px 0px 0px 15px;
}
.shopping_list_end_4{
border-right:solid 1px #666;
margin:10px 0px 0px 15px;
padding-right:10px;
}
.shopping_list_end_yellow{
color:#bd3e00;
}
</style>
</head>

 

<body>
<!--中间部分开始-->

<div id="main">

<!--为您推荐商品开始-->

<div id="shopping_commend_sort">
<div class="shopping_commend_sort_left">
<ul id="ul1">
<li class="shopping_commend_list_1">·<a href="#" class="blue">JavaScript DOM编程艺术</a></li>
<li class="shopping_commend_list_2">¥39.00</li>
<li class="shopping_commend_list_3">¥29.30</li>
<li class="shopping_commend_list_4"><a href="javascript:buyProduct('ul1')" class="shopping_yellow">购买</a></li>
</ul>
<ul id="ul2">
<li class="shopping_commend_list_1">·<a href="#" class="blue">解禁(当当网独家首发)</a></li>
<li class="shopping_commend_list_2">¥28.00</li>
<li class="shopping_commend_list_3">¥19.40</li>
<li class="shopping_commend_list_4"><a href="javascript:buyProduct('ul2')" class="shopping_yellow">购买</a></li>
</ul>
<ul id="ul3">
<li class="shopping_commend_list_1">·<a href="#" class="blue">地王之王(金融危机下房地产行...</a></li>
<li class="shopping_commend_list_2">¥32.80</li>
<li class="shopping_commend_list_3">¥25.10</li>
<li class="shopping_commend_list_4"><a href="javascript:buyProduct('ul3')" class="shopping_yellow">购买</a></li>
</ul>
<ul id="ul4">
<li class="shopping_commend_list_1">·<a href="#" class="blue">逃庄</a></li>
<li class="shopping_commend_list_2">¥36.00</li>
<li class="shopping_commend_list_3">¥27.70</li>
<li class="shopping_commend_list_4"><a href="javascript:buyProduct('ul4')" class="shopping_yellow">购买</a></li>
</ul>
</div>

<div class="shopping_commend_sort_left">
<ul id="ul5">
<li class="shopping_commend_list_1">·<a href="#" class="blue">深入浅出MySQL数据库开发、优...</a></li>
<li class="shopping_commend_list_2">¥59.00</li>
<li class="shopping_commend_list_3">¥47.20</li>
<li class="shopping_commend_list_4"><a href="javascript:buyProduct('ul5')" class="shopping_yellow">购买</a></li>
</ul>
<ul id="ul6">
<li class="shopping_commend_list_1">·<a href="#" class="blue">大玩家(马未都、王刚推荐!央...</a></li>
<li class="shopping_commend_list_2">¥34.80</li>
<li class="shopping_commend_list_3">¥20.60</li>
<li class="shopping_commend_list_4"><a href="javascript:buyProduct('ul6')" class="shopping_yellow">购买</a></li>
</ul>
<ul id="ul7">
<li class="shopping_commend_list_1">·<a href="#" class="blue">都市风水师--官场风水小说:一...</a></li>
<li class="shopping_commend_list_2">¥39.80</li>
<li class="shopping_commend_list_3">¥30.50</li>
<li class="shopping_commend_list_4"><a href="javascript:buyProduct('ul7')" class="shopping_yellow">购买</a></li>
</ul>
<ul id="ul8">
<li class="shopping_commend_list_1">·<a href="#" class="blue">国戏(以麻将术语解读宦海沉浮...</a></li>
<li class="shopping_commend_list_2">¥25.00</li>
<li class="shopping_commend_list_3">¥17.30</li>
<li class="shopping_commend_list_4"><a href="javascript:buyProduct('ul8')" class="shopping_yellow">购买</a></li>
</ul>
</div>

</div>

<div class="shopping_list_top">您已选购以下商品</div>
<div class="shopping_list_border">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr class="shopping_list_title">
<td class="shopping_list_title_1">商品名</td>
<td class="shopping_list_title_2">单品积分</td>
<td class="shopping_list_title_3">市场价</td>
<td class="shopping_list_title_4">当当价</td>
<td class="shopping_list_title_5">数量</td>
<td class="shopping_list_title_6">删除</td>
</tr>
</tbody>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="myTableProduct">
<tbody>
<tr class="shopping_product_list" id="shoppingProduct_01">
<td class="shopping_product_list_1"><a href="#" class="blue">私募(首部披露资本博弈秘密的金融...</a></td>
<td class="shopping_product_list_2"><label>189</label></td>
<td class="shopping_product_list_3">¥<label>32.00</label></td>
<td class="shopping_product_list_4">¥<label>18.90 </label>(59折)</td>
<td class="shopping_product_list_5"><input type="text" value="1" οnblur="productCount()"></td>
<td class="shopping_product_list_6"><a href="javascript:deleteProduct('shoppingProduct_01')" class="blue">删除</a></td>
</tr>
<tr class="shopping_product_list" id="shoppingProduct_02">
<td class="shopping_product_list_1"><a href="#" class="blue"> 小团圆(张爱玲最神秘小说遗稿)</a></td>
<td class="shopping_product_list_2"><label>173</label></td>
<td class="shopping_product_list_3">¥<label>28.00</label></td>
<td class="shopping_product_list_4">¥<label>17.30</label>(62折)</td>
<td class="shopping_product_list_5"><input type="text" value="1" οnblur="productCount()"></td>
<td class="shopping_product_list_6"><a href="javascript:deleteProduct('shoppingProduct_02')" class="blue">删除</a></td>
</tr>

<tr class="shopping_product_list" id="shoppingProduct_03">
<td class="shopping_product_list_1"><a href="#" class="blue">不抱怨的世界(畅销全球80国的世界...</a></td>
<td class="shopping_product_list_2"><label>154</label></td>
<td class="shopping_product_list_3">¥<label>24.80</label></td>
<td class="shopping_product_list_4">¥<label>15.40</label> (62折)</td>
<td class="shopping_product_list_5"><input type="text" value="2" οnblur="productCount()"></td>
<td class="shopping_product_list_6"><a href="javascript:deleteProduct('shoppingProduct_03')" class="blue">删除</a></td>
</tr>
<tr class="shopping_product_list" id="shoppingProduct_04">
<td class="shopping_product_list_1"><a href="#" class="blue">福玛特双桶洗衣机XPB20-07S</a></td>
<td class="shopping_product_list_2"><label>358</label></td>
<td class="shopping_product_list_3">¥<label>458.00</label></td>
<td class="shopping_product_list_4">¥<label>358.00</label> (78折)</td>
<td class="shopping_product_list_5"><input type="text" value="1" οnblur="productCount()"></td>
<td class="shopping_product_list_6"><a href="javascript:deleteProduct('shoppingProduct_04')" class="blue">删除</a></td>
</tr>
<tr class="shopping_product_list" id="shoppingProduct_05">
<td class="shopping_product_list_1"><a href="#" class="blue">PHP和MySQL Web开发 (原书第4版)</a></td>
<td class="shopping_product_list_2"><label>712</label></td>
<td class="shopping_product_list_3">¥<label>95.00</label></td>
<td class="shopping_product_list_4">¥<label>71.20</label> (75折)</td>
<td class="shopping_product_list_5"><input type="text" value="1" οnblur="productCount()"></td>
<td class="shopping_product_list_6"><a href="javascript:deleteProduct('shoppingProduct_05')" class="blue">删除</a></td>
</tr>
<tr class="shopping_product_list" id="shoppingProduct_06">
<td class="shopping_product_list_1"><a href="#" class="blue">法布尔昆虫记</a>(再买¥68.30即可参加“满199元减10元现金”活动)</td>
<td class="shopping_product_list_2"><label>10</label></td>
<td class="shopping_product_list_3">¥<label>198.00</label></td>
<td class="shopping_product_list_4">¥<label>130.70</label> (66折)</td>
<td class="shopping_product_list_5"><input type="text" value="1" οnblur="productCount()"></td>
<td class="shopping_product_list_6"><a href="javascript:deleteProduct('shoppingProduct_06')" class="blue">删除</a></td>
</tr>
</tbody>
</table>
<div class="shopping_list_end">
<ul>
<li class="shopping_list_end_1"><input name="" type="image" ></li>
<li class="shopping_list_end_2">¥<label id="product_total">626.90</label></li>
<li class="shopping_list_end_3">商品金额总计:</li>
<li class="shopping_list_end_4">您共节省金额:¥<label class="shopping_list_end_yellow" id="product_save">233.70</label><br>
可获商品积分:<label class="shopping_list_end_yellow" id="product_integral">1750.00</label>
</li>
</ul>
</div>
</div>
</div>

<script type="text/javascript" src="https://qunarzz.com/jquery/prd/jquery-1.7.2.js"></script>
<script type="text/javascript">
function shopping_commend_show(){
var imgid=$("#shopping_commend_arrow"); //图片箭头
var divid=$("#shopping_commend_sort"); //层的id

if(divid.css("display")=="none"){
divid.css("display","block");
}else{
divid.css("display","none");
}
}

//删除
function deleteProduct(obj){
var flag=confirm("您确定要删除此商品吗?");
if(flag){
$("#"+obj).remove();
productCount();
}else{
return;
}
}

$(function(){
productCount();
});

//计算商品总额的方法
function productCount(){
var total=0; //总价
var save=0; //节省金额
var integral=0; //积分

var point;//每一行的单品积分
var price;//每一行的市场价
var ddprice;//每一行的当当价
var number;//每一行的数量

var mytable=$("#myTableProduct tr");
for(var i=0;i<mytable.length;i++){//循环每一行
point=$("#myTableProduct tr:eq("+i+") td:eq(1) label:eq(0)").html();
price=$("#myTableProduct tr:eq("+i+") td:eq(2) label:eq(0)").html();
ddprice=$("#myTableProduct tr:eq("+i+") td:eq(3) label:eq(0)").html();
number=$("#myTableProduct tr:eq("+i+") td:eq(4) input:eq(0)").val();

if(isNaN(number)){
alert("您输入的商品数量格式有误,请重新输入!");
$("#myTableProduct tr:eq("+i+") td:eq(4) input:eq(0)").select();
return;
}
total+=ddprice*number;
save+=(price-ddprice)*number;
integral+=point*number;
}
$("#product_total").html(total.toFixed(2));
$("#product_save").html(save.toFixed(2));
$("#product_integral").html(integral.toFixed(2));
}

var mycount=0;
function buyProduct(obj){
var bookName=$("#"+obj+" li:eq(0)").text().substring(1);
var bookPrice=$("#"+obj+" li:eq(1)").text().substring(1);
var ddPrice=$("#"+obj+" li:eq(2)").text().substring(1);
var flag=true;

var rebate=ddPrice/bookPrice*100;

var mytable1=$("#myTableProduct tr");
for(var i=0;i<mytable1.length;i++){//循环每一行
name=$("#myTableProduct tr:eq("+i+") td:eq(0) a:eq(0)").text();
if(name==bookName){
var sum=$("#myTableProduct tr:eq("+i+") td:eq(4) input:eq(0)").val();
sum++; //如果存在则数量加1
$("#myTableProduct tr:eq("+i+") td:eq(4) input:eq(0)").val(sum);
productCount();
return;
}
}
//如果不存在,则在已购商品列表中添加一行
mycount++;
var str="<tr class=\"shopping_product_list\" id=\"addProduct_"+mycount+"\">";
str+="<td class=\"shopping_product_list_1\"><a href=\"#\" class=\"blue\">"+bookName+"</a></td>";
str+="<td class=\"shopping_product_list_2\"><label>100</label></td>";
str+="<td class=\"shopping_product_list_3\">¥<label>"+bookPrice+"</label></td>";
str+="<td class=\"shopping_product_list_4\">¥<label>"+ddPrice+"</label> ("+rebate.toFixed(0)+"折)</td>";
str+="<td class=\"shopping_product_list_5\"><input type=\"text\" value=\"1\" onBlur=\"productCount()\"></td>";
str+="<td class=\"shopping_product_list_6\"><a href=\"javascript:deleteProduct('addProduct_"+mycount+"')\" class=\"blue\">删除</a></td></tr> ";
$("#myTableProduct").prepend(str);
productCount();
}

</script>

</body>
</html>

转载于:https://www.cnblogs.com/ll-taj/p/6164271.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/572920.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

html5 客户端数据缓存机制,深入理解HTML5离线缓存机制

TML5提供了一种离线应用缓存机制&#xff0c;使得网页应用可以离线使用&#xff0c;这种机制在移动端浏览器上支持度非常广&#xff0c;所有版本的android和ios浏览器都能很好的支持。我们可以放心的使用该特性来加速移动端页面的访问速度。开启离线缓存的步骤也非常简单&#…

安卓手机上运行 PC-E500 程序

目录 第1章安卓手机上运行 PC-E500 程序 1 1 PockEmul 1 2 下载 1 3 打包BASIC程序 2 4 配置PC-E500模拟器 5 5 载入e500.pkm 7 6 载入40000.bin 8 7 解包 10 第1章安卓手机上运行 PC-E500 程序 1 PockEmul 安卓手机上运行PC-E500程序&#xff0c;需要…

2021安徽省高考成绩怎么查询系统,2021年安徽省教育招生考试院成绩查询登录入口...

一、2020年安徽高考成绩查询登录入口二、安徽高考成绩查询新闻资讯最新消息!安徽高考预计7月23日划定各批次录取线并公布高考成绩!7月14日上午&#xff0c;记者跟随省人大代表、省政协委员们一同走进安徽省教育招生考试院网评现场。“今年&#xff0c;我省高考的网上评卷工作继…

Java Web之网上购物系统(提交订单、查看我的订单)

作业终于做完了&#xff0c;好开心。。。。。。虽然这一周经历不是那么顺利&#xff0c;但是觉得还是收获了不少&#xff0c;有过想哭的冲动&#xff0c;代码不会写&#xff0c;事情办不好&#xff0c;各种发愁。空间里发小发了带父母出去游玩的照片&#xff0c;瞬间能量值不知…

河北大学计算机专业调剂,【计算机考研调剂】河北大学2021级硕士研究生预调剂信息统计的通知...

广大考生&#xff1a;根据河北大学2021年硕士研究生招生计划&#xff0c;我院拟招收校内外调剂考生&#xff0c;欢迎广大考生调剂到我院。调剂要求&#xff1a;1、按照学校要求&#xff0c;申报我院调剂考生&#xff0c;初试总成绩和单科成绩不低于教育部公布的《2021年全国硕士…

撸表情开发过程中使用腾讯云存储的接入实例分享

推荐一下一个有趣的表情包收集网站&#xff0c;也可以在线制作表情包&#xff0c;欢迎访问&#xff1a;撸表情 撸表情&#xff08;http://www.lubiaoqing.com&#xff09;这个网站是业余时间开发的一个网站&#xff0c;涉及到大量表情包的检索和存储&#xff0c;个人服务器肯定…

html路径详解,详解HTML相对路径和绝对路径

相对路径&#xff1a;以引用文件之网页所在位置为参考基础&#xff0c;而建立出的目录路径。因此&#xff0c;当保存于不同目录的网页引用同一个文件时&#xff0c;所使用的路径将不相同&#xff0c;故称之为相对。绝对路径&#xff1a;以Web站点根目录为参考基础的目录路径。之…

#65279导致页面顶部空白一行解决方法

今天做了两个静态html页面&#xff0c;在浏览器中测试的时候&#xff0c;发现其中一个html页面的顶部多出了些许空白&#xff0c;而另一个页面显示正常。在浏览器中进行了审查对比&#xff0c;发现有空白的那个页面的head标签里面的元素全部跑到了body里面&#xff0c;而且body…

计算机应用技术自我分析,计算机应用*个人自我鉴定

第1篇&#xff1a;计算机应用*个人自我鉴定时光匆匆溜走&#xff0c;短短三年的大学生活即将过去。在菁菁校园中&#xff0c;老师的教诲&#xff0c;同学的友爱以及各方面&#xff0c;使我获得了许多知识&#xff0c;懂得了许多道理。为了更好地适应社会的需要&#xff0c;我在…

怎么把桌面计算机放到快速启动栏,怎么把桌面图标放到快速启动栏

1. 如何把桌面图标放于快速启动栏拖动图标到任务栏&#xff0c;之后删除桌面图标不行的话点击“开始”菜单→“运行”命令&#xff0c;在弹出的“运行”对话框中输入 regsvr32 /n /i:u shell32 后回车&#xff0c;丢失的图标便又重新回到快速启动栏了再不行的话在Windows操作系…

html5 自适应手机布局,科技常识:html5移动端自适应布局的实现

今天小编跟大家讲解下有关html5移动端自适应布局的实现 &#xff0c;相信小伙伴们对这个话题应该有所关注吧&#xff0c;小编也收集到了有关html5移动端自适应布局的实现 的相关资料&#xff0c;希望小伙伴们看了有所帮助。场景&#xff1a;为适应各种大小的屏幕自适应布局我知…

js 两个map合并为一个map_ArcGIS API for JS3.x教程二:构建第一个简单的程序

本文衔接上文&#xff1a;不睡觉的怪叔叔&#xff1a;ArcGIS API for JS3.x教程一&#xff1a;本地开发环境配置​zhuanlan.zhihu.com一、创建简单的HTML文档创建一个简单的HTML文档&#xff1a;<!DOCTYPE html> <html lang"en"> <head><meta c…

hibernate、easyui、struts2整合

<!DOCTYPE html> <html> <head> <meta charset"UTF-8"> <title>学生表</title> <!-- 1jQuery的js包 --> <script type"text/javascript" src"jquery-easyui-1.4.4/jquery.min.js"></script&…

selinux= 为 disabled_CentOS7关闭防火墙和SELinux

关闭防火墙查看防火墙状态[rootlocalhost ~]# systemctl status firewalld临时关闭&#xff08;下次开机启动&#xff0c;自动启动防火墙&#xff09;[rootlocalhost ~]# systemctl stop firewalld永久关闭防火墙&#xff08;开机启动时不在启动&#xff09;[rootlocalhost ~]#…

selenium 基本的键盘方法

selenium 基本的键盘方法 今晚不想加班&#xff0c;于是赶紧回来看看书&#xff1a; 1.下了selenium的小工具&#xff1a;FireBug/FirePath。 2.确定了看书顺序&#xff0c;我觉得难度低点开始比较好&#xff0c;所以我还是先看基于Python的selenium&#xff0c;另一本书再看把…

计算机主机组成部分和功能,电脑的组成部分及作用

对于很多人来讲&#xff0c;电脑的使用似乎是一件很稀松平常的事情了。但是对于一些新手或者是一些初学者来说&#xff0c;电脑的相关组成部件还有相应的作用都不是很熟悉&#xff0c;那么电脑的组成部分及作用是什么呢?下面是学习啦小编收集的关于电脑的组成部分及作用&#…

android8 通知呼吸灯_正在消失的功能,为什么越来越多的手机没有呼吸灯?你知道原因吗...

正在消失的功能&#xff0c;为什么越来越多的手机没有呼吸灯&#xff1f;你知道原因吗其实说到手机呼吸灯&#xff0c;大家应该都不陌生&#xff0c;毕竟如果你有心心念念的人儿&#xff0c;每次呼吸灯闪烁&#xff0c;都会迫不及待的打开手机查看消息&#xff0c;想看看是不是…

asp 使用TreeView控件

这段代码为了使用 TreeNodeCheckChanged 事件&#xff0c;会有回刷新的效果&#xff1b; 不喜欢的可查看改进版&#xff0c;利用js控制选择操作&#xff0c;无界面刷新&#xff0c; “http://www.cnblogs.com/GoCircle/p/6231985.html”&#xff1b; 前台代码 <style>.tn…

巴川数据科学炼成记_【脑王直通车】小小记忆高手炼成记

“ 记住150个随机数字&#xff0c;你需要多久&#xff1f;【脑王直通车】第8站到来&#xff0c;杨老师将他在《最强大脑》比赛中运用的记忆方法倾囊相授&#xff0c;孩子们变身小小记忆高手&#xff01;”记忆探秘你们知道记忆是什么吗&#xff1f;我们从小到大&#xff0c;无论…

2013年4月管理计算机应用,全国2013年4月高等教育自学考试管理系统中计算机应用试题及答案...

我自己整合过的,相当的详细,几乎设计了出现的所有的知识的哦!!全国2013年4月高等教育自学考试管理系统中计算机应用试题课程代码&#xff1a;00051请考生按规定用笔将所有试题的答案涂、写在答题纸上。选择题部分注意事项&#xff1a;1. 答题前&#xff0c;考生务必将自己的考试…