<HTML>
<HEAD>
<TITLE>Shopping Bag Manager</TITLE>
<STYLE TYPE="text/css">
<!--
TD {font-weight: bold; margin-left: 20; margin-right: 20; padding: 10}
//-->
</STYLE>
</HEAD>
<BODY onLoad="freshStart(); makeProducts();" LINK=BLUE ALINK=BLUE VLINK=BLUE>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="inventory.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
// Define control variables
var gimmeControl = false;
var browseControl = false;
var curCLoc = -1;
var curPLoc = -1;
var infoStr = '';
var shoppingBag;
// Define a shopping bag constructor
// then create a new Bag
function Bag() {
this.taxRate = .06;
this.taxTotal = 0;
this.shipRate = .02;
this.shipTotal = 0;
this.subTotal = 0;
this.bagTotal = 0;
this.things = new Array();
}
shoppingBag = new Bag();
// This function displays links to
// all the available categories
function showStore() {
gimmeControl = false;
var header = '<HTML><TITLE>Category</TITLE><BODY BGCOLOR=FFFFFF>';
var intro = '<H2>Shopping Bag Product Categories</H2><B>';
var footer = '</DL></BLOCKQUOTE></BODY></HTML>';
var storeStr = '<BLOCKQUOTE><DL>';
for (var i = 0; i < categorySet.length; i++) {
storeStr += '<DT><A HREF="javascript: parent.frames[1].reCall(' + i + ', 0);">' +
categorySet[i].name + '</A>' +
'<DD>' + categorySet[i].description + '<BR><BR>';
}
infoStr = header + intro + storeStr + footer;
parent.frames[0].location.replace("javascript: parent.frames[1].infoStr");
}
// Define a function to manage
// opening the product search
function portal() {
gimmeControl = false;
parent.frames[0].location.href = "search/index.html";
}
// Display a product depending on the current values of the
// category number (curCLoc) and product number (curPLoc)
function display(cOffset, pOffset) {
if(!browseControl) {
alert("Start shopping by selecting a product category from Show All Categories or " +
"searching products from Product Search.");
return;
}
gimmeControl = true;
if (curPLoc + pOffset < 0 || curPLoc + pOffset == categorySet[curCLoc].prodLine.length) {
if (curPLoc + pOffset < 0) {
if (curCLoc - 1 < 0) { curCLoc = categorySet.length - 1; }
else { curCLoc--; }
curPLoc = categorySet[curCLoc].prodLine.length - 1;
}
else if (curPLoc + pOffset == categorySet[curCLoc].prodLine.length) {
if (curCLoc + 1 == categorySet.length) { curCLoc = 0; }
else { curCLoc++; }
curPLoc = 0;
}
}
else {
if (curCLoc + cOffset < 0 || curCLoc + cOffset == categorySet.length) {
curCLoc = (curCLoc + cOffset < 0 ? categorySet.length - 1 : 0);
}
else { curCLoc += cOffset; }
if (cOffset == -1 || cOffset == 1) { curPLoc = 0; }
else if (pOffset == 0) {
curPLoc = (curPLoc >= categorySet[curCLoc].prodLine.length ? 0 : curPLoc)
}
else { curPLoc = curPLoc + pOffset; }
}
infoStr = '<HTML><HEAD><TITLE>Product Name</TITLE></HEAD>' +
'<BODY><TABLE CELLPADDING=3><TR><TD VALIGN=TOP COLSPAN=2>' +
'<FONT FACE=Tahoma><H2>Shopping Bag: <I>' + categorySet[curCLoc].name + '</I></H2>' +
'<TR>' +
'<TD VALIGN=TOP><IMG SRC="' + categorySet[curCLoc].prodLine[curPLoc].icon.src +
'"></TD><TD VALIGN=TOP><FONT FACE=Tahoma>' +
'<B>Name: </B>' + categorySet[curCLoc].prodLine[curPLoc].name + '<BR>' +
'<B>Description: </B>' + categorySet[curCLoc].prodLine[curPLoc].description + '<BR>' +
'<B>Price: </B> $' + numberFormat(categorySet[curCLoc].prodLine[curPLoc].price) + '/' +
categorySet[curCLoc].prodLine[curPLoc].unit + '<BR>' +
'<B>PLU: </B>' + categorySet[curCLoc].prodLine[curPLoc].plu + '</TD></TR></TABLE></BODY></HTML>';
parent.frames[0].location.href = "javascript: parent.frames[1].infoStr";
}
// Used for navigation by setting values
// curCLoc and curPLoc independently instead
// of setting them according to their current
// value as done in display()
function reCall(cReset, pReset) {
browseControl = true;
curCLoc = cReset;
curPLoc = pReset;
display(0, 0);
}
// This function adds a product to a user's
// bag only if it is not there already
function gimmeOne() {
if (!gimmeControl) {
alert("Nothing on this screen to give you.");
return;
}
for (var i = 0; i < shoppingBag.things.length; i++) {
if (categorySet[curCLoc].prodLine[curPLoc].plu == shoppingBag.things[i].plu) {
alert("That's already in your bag. You can change the quantity by choosing View/Change Bag.");
return;
}
}
shoppingBag.things[shoppingBag.things.length] = categorySet[curCLoc].prodLine[curPLoc];
shoppingBag.things[shoppingBag.things.length - 1].itemQty = 1;
shoppingBag.things[shoppingBag.things.length - 1].category = categorySet[curCLoc].name;
alert("OK. You put the " + shoppingBag.things[shoppingBag.things.length - 1].name + " in your bag.");
}
// Define a function to iterate through all the
// products in the user's bag and display them
// in a form for user changes
function showBag() {
if (shoppingBag.things.length == 0) {
alert("Your bag is currently empty. Put some stuff in.");
return;
}
gimmeControl = false;
var header = '<HTML><HEAD><TITLE>Your Shopping Bag</TITLE>' +
'</HEAD><BODY BGCOLOR=FFFFFF onLoad="parent.frames[1].runningTab(document.forms[0]);">';
var intro = '<H2>Your Shopping Bag!!!</H2><FORM onReset="setTimeout(\'parent.frames[1].runningTab(document.forms[0])\', 25);">';
var tableTop = '<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=5>' +
'<TR><TH><B>Index' +
'<TH><B>Product<TH><B>Category' +
'<TH><B>PLU<TH><B>Unit Price' +
'<TH><B>Quantity<TH><B>Product Total' +
'<TH><B>Remove' +
'</TR>';
var itemStr = '';
for (var i = 0; i < shoppingBag.things.length; i++) {
itemStr += '<TR>' +
'<TD ALIGN=CENTER>' + (i + 1) + '</TD>' +
'<TD>' + shoppingBag.things[i].name + '</TD>' +
'<TD>' + shoppingBag.things[i].category + '</TD>' +
'<TD>' + shoppingBag.things[i].plu + '</TD>' +
'<TD ALIGN=RIGHT>$' + parent.frames[1].numberFormat(shoppingBag.things[i].price) + '</TD>' +
'<TD ALIGN=CENTER>' + parent.frames[1].genSelect(shoppingBag.things[i].price, shoppingBag.things[i].itemQty, i) + '</TD>' +
'<TD ALIGN=CENTER><INPUT TYPE=TEXT SIZE=10 VALUE="' + parent.frames[1].numberFormat(shoppingBag.things[i].price * shoppingBag.things[i].itemQty) + '" onFocus="this.blur();"></TD>' +
'<TD ALIGN=CENTER><INPUT TYPE=CHECKBOX></TD>' +
'</TR>';
}
var tableBottom = '<TR>' +
'<TD ALIGN=RIGHT COLSPAN=6>SubTotal:</TD>' +
'<TD ALIGN=CENTER><INPUT TYPE=TEXT SIZE=10 NAME="subtotal" onFocus="this.blur();"></TD></TR>' +
'<TR>' +
'<TD ALIGN=RIGHT COLSPAN=6> + 6% Tax:</TD>' +
'<TD ALIGN=CENTER><INPUT TYPE=TEXT SIZE=10 NAME="tax" onFocus="this.blur();"></TD></TR>' +
'<TR>' +
'<TD ALIGN=RIGHT COLSPAN=6> + 2% Shipping:</TD>' +
'<TD ALIGN=CENTER><INPUT TYPE=TEXT SIZE=10 NAME="ship" onFocus="this.blur();"></TD></TR>' +
'<TR>' +
'<TD ALIGN=RIGHT COLSPAN=3><INPUT TYPE=BUTTON VALUE="Check Out" onClick="parent.frames[1].checkOut(this.form);"></TD>' +
'<TD ALIGN=RIGHT><INPUT TYPE=RESET VALUE="Reset Qtys"></TD>' +
'<TD ALIGN=RIGHT><INPUT TYPE=BUTTON VALUE="Change Bag" onClick="parent.frames[1].changeBag(this.form, true);"></TD>' +
'<TD ALIGN=RIGHT>Total:</TD>' +
'<TD ALIGN=CENTER><INPUT TYPE=TEXT NAME="total" SIZE=10 onFocus="this.blur();"></TD></TR>';
var footer = '</TABLE></FORM></BODY></HTML>';
infoStr = header + intro + tableTop + itemStr + tableBottom + footer;
parent.frames[0].location.replace('javascript: parent.frames[1].infoStr');
}
// Generate dynamic SELECT lists according
// to a price aggregate, and set the OPTION
// that matches the qty as SELECTED
function genSelect(priceAgr, qty, idx) {
var selStr = '<SELECT onChange="this.form.elements[' + (idx * 3 + 1) +
'].value = this.options[this.selectedIndex].value; parent.frames[1].runningTab(this.form)
没有合适的资源?快使用搜索试试~ 我知道了~
JavaScript应用程序经典实例全书源码
共286个文件
gif:138个
jpg:62个
html:56个
需积分: 10 19 下载量 44 浏览量
2018-01-31
15:26:48
上传
评论
收藏 1.03MB RAR 举报
温馨提示
JavaScript应用程序经典实例全书源码JavaScript应用程序经典实例全书源码JavaScript应用程序经典实例全书源码
资源推荐
资源详情
资源评论
收起资源包目录
JavaScript应用程序经典实例全书源码 (286个子文件)
bag.cgi 2KB
currency2.gif 30KB
bills.gif 29KB
gold.gif 26KB
currency1.gif 25KB
fist.gif 17KB
image_machine.gif 12KB
snake.gif 9KB
currency1thumb.gif 8KB
billsthumb.gif 8KB
currency2thumb.gif 8KB
city.gif 8KB
turkey.gif 7KB
sun.gif 7KB
walrus.gif 7KB
goldthumb.gif 7KB
castle.gif 7KB
stereo.gif 7KB
oven.gif 6KB
robot.gif 6KB
clown.gif 6KB
logo.gif 6KB
tower.gif 6KB
fries.gif 5KB
television.gif 5KB
pig.gif 5KB
fistthumb.gif 5KB
speaker.gif 5KB
logo1.gif 5KB
remote.gif 5KB
lighthouse.gif 5KB
hammer.gif 5KB
cheese.gif 5KB
dragon.gif 5KB
cactus.gif 4KB
crane.gif 4KB
bird.gif 4KB
camcorder.gif 4KB
chips.gif 4KB
judo.gif 4KB
gator.gif 4KB
eggs.gif 4KB
bear.gif 4KB
toaster.gif 4KB
gator.gif 4KB
dress.gif 4KB
reindeer.gif 4KB
igloo.gif 4KB
dryer.gif 4KB
camera.gif 4KB
cow.gif 4KB
bowtie.gif 4KB
piano.gif 4KB
tree.gif 3KB
dog.gif 3KB
watch.gif 3KB
chainsaw.gif 3KB
cellphone.gif 3KB
guitar.gif 3KB
radio.gif 3KB
drumstick.gif 3KB
barn.gif 3KB
jacket.gif 3KB
logo2.gif 3KB
necktie.gif 3KB
logo3.gif 3KB
washer.gif 3KB
trumpet.gif 3KB
purse.gif 3KB
glove.gif 3KB
pliers.gif 3KB
juicemoose.gif 3KB
cycle.gif 3KB
dude.gif 3KB
seniorexec.gif 3KB
drill.gif 3KB
tornado.gif 2KB
stake.gif 2KB
lawnmower.gif 2KB
cowprod.gif 2KB
shrimp.gif 2KB
hairdryer.gif 2KB
bongos.gif 2KB
notes.gif 2KB
automate.gif 1KB
reindeerout.gif 1KB
reindeerover.gif 1KB
guideover.gif 1KB
walrusout.gif 1KB
walrusover.gif 1KB
turkeyover.gif 1KB
turkeyout.gif 1KB
snakeout.gif 1KB
snakeover.gif 1KB
craneover.gif 1014B
craneout.gif 1013B
guideout.gif 1010B
gatorout.gif 1010B
gatorover.gif 1010B
birdover.gif 992B
共 286 条
- 1
- 2
- 3
资源评论
难以忘怀的我
- 粉丝: 0
- 资源: 48
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 软件仿真多机串行通信.doc
- Python大作业:音乐播放软件(爬虫+可视化+数据分析+数据库)
- 课程设计-python爬虫-爬取日报,爬取日报文章后存储到本地,附带源代码+课程设计报告
- 软件和信息技术服务行业投资与前景预测.pptx
- 课程设计-基于SpringBoot + Mybatis+python爬虫NBA球员数据爬取可视化+源代码+文档+sql+效果图
- 软件品质管理系列二项目策划规范.doc
- 基于TensorFlow+PyQt+GUI的酒店评论情感分析,支持分析本地数据文件和网络爬取数据分析+源代码+文档说明+安装教程
- 软件定义无线电中的模拟电路测试技术.pptx
- 软件开发协议(作为技术开发合同附件).doc
- 软件开发和咨询行业技术趋势分析.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功