";
document.cookie = tempi + temp_end;
// alert(document.cookie);
// clear the deleted row
for (inc2=0; inc2<3; inc2++) {
//alert();
form.elements[((itemN-1)*4)+inc2].value=0;
}
totalTable();
// reload document
//window.history.go(0);
}
function tableOfNRows(n) {
document.write("<TABLE BORDER COLS=4 WIDTH='100%' >");
//write header
document.write("<TR><TD><CENTER>Item</CENTER></TD><TD><CENTER>Type</CENTER></TD><TD><CENTER>Item Cost<FONT SIZE=-2><BR>(in AUD)</FONT></CENTER></TD>");
document.write("<TD></TD></TR>");
i = 0;
do {
document.write("<TR><TD align=center><INPUT TYPE=TEXT SIZE=15 NAME='item" + i +"'" );
document.write(" VALUE='" + getElement(option_separator,(i*5)+1,document.cookie) + "' ");
document.write("></TD>");
document.write("<TD align=center><INPUT TYPE=TEXT SIZE=15 NAME='type" + i + "'" );
document.write(" VALUE='" + getElement(option_separator,(i*5)+2,document.cookie) + "' ");
document.write("></TD>");
document.write("<TD><CENTER>$<INPUT TYPE=TEXT SIZE=6 NAME='cost" + i + "'");
document.write(" VALUE='" + getElement(option_separator,(i*5)+3,document.cookie) + "' ");
document.write("></CENTER></TD>");
document.write("<TD><INPUT TYPE='BUTTON' VALUE='Remove item' NAME='Remove" + i );
document.write("' onclick='removeItem(item_separator," + (i+1) + ", document.cookie, this.form )'></TD></TR>");
i++;
}
while(i<n)
//write footer
document.write("<TR><TD></TD><TD><DIV ALIGN=RIGHT><B>Total =</B></DIV></TD>");
document.write("<TD><CENTER>$<INPUT TYPE='TEXT' SIZE='6' NAME='total'></CENTER></TD><TD></TD><TD></TD><TD></TD></TR>");
document.write("</TABLE>");
}
function totalTable() {
//for x = 1 to number of items
// add all the items offset by n together
//alert("in totalTable");
document.TrolleyContents.total.value = 0;
offset=6;
jumper=4;
items = NumberOfItems(document.cookie, option_separator, item_separator );
for (x=0; x<items; x++)
{
index = (x*jumper)+offset;
jumpertemp=(document.TrolleyContents.elements[index].value) *1;
if (jumpertemp == 0) items = items+1;
// if jumpertemp isn't a number then just increase items by one - must be a deleted one
document.TrolleyContents.total.value= (document.TrolleyContents.total.value*1) + jumpertemp;
}
}
function SendTrolley() {
temp="";
inc=0;
do {
//Add name
temp=temp+"Name = " + document.TrolleyContents.elements[inc].value + " : ";
inc++;
//Add type
temp=temp+"Type = " + document.TrolleyContents.elements[inc].value + " : ";
inc++;
//Add price
temp=temp+"Price = $" + document.TrolleyContents.elements[inc].value + "\n";
inc++;
//Skip remove button
inc++;
}while(inc<(document.TrolleyContents.elements.length -10));
temp+="\nTotal order price = $" + document.TrolleyContents.elements[inc].value;
document.TrolleyContents.Items.value = temp;
}
---
*****@*****
zif email:zif@163.net
http://www.xiamencity.com
*****@*****1999-12-25
关键词:cookie的技巧与购物车