Stort problem HJÆLP
Jeg har et problem !!!Jeg har følgende kode, og vil gerne have at de informationer der bliver vist på siden kan emailes til mig. Det er et bestillingssystem ( e-commerce ).
HJÆLP... hvad skal jeg gøre ?
KODEN :
<HTML>
<!-- JShop v2.2 (22nd October 1997) -->
<!-- by Gareth Lancaster @ Whorl (www.whorl.co.uk) -->
<!-- SHOPPING BASKET -->
<HEAD>
<TITLE>Shopping Basket</TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
// showItems() - displays shopping basket in a table
function showItems() {
index = document.cookie.indexOf("TheBasket");
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
fulllist = document.cookie.substring(countbegin, countend);
totprice = 0;
document.writeln('<FORM NAME="updateform">');
document.writeln('<TABLE BORDER>');
document.writeln('<TR><TD><b><font size=-1>Item</font></b></TD><TD><b><font size=-1>Quantity</font></b></TD><TD><b><font size=-1>Cost Each</font></b></TD><td><b><font size=-1>Total Cost</font></b><TD><b><font size=-1>Action</font></b></TD></TR>');
itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == '[') {
itemstart = i+1;
thisitem = 1;
} else if (fulllist.substring(i,i+1) == ']') {
itemend = i;
thequantity = fulllist.substring(itemstart, itemend);
itemtotal = 0;
itemtotal = (eval(theprice*thequantity));
temptotal = itemtotal * 100;
totprice = totprice + itemtotal;
itemlist=itemlist+1;
document.write('<tr><td>'+theitem+'</td>');
document.write('<td align=right><INPUT TYPE=TEXT NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=3></td><td align=right>'+theprice+'</td><td align=right>'+top.menu.alterError(itemtotal)+'</td><td><a href="java script:removeItem('+itemlist+')">Remove</a> <a href="java script:amendItem('+itemlist+',document.updateform.quant'+itemlist+'.value)">Update</a></td></tr>');
} else if (fulllist.substring(i,i+1) == '|') {
if (thisitem==1) theitem = fulllist.substring(itemstart, i);
if (thisitem==2) theprice = fulllist.substring(itemstart, i);
thisitem++;
itemstart=i+1;
}
}
document.writeln('<tr><td colspan=3><b>Total</b></td><td align=right>'+top.menu.alterError(totprice)+'</td><td></td></tr>');
document.writeln('</TABLE>');
document.writeln('</FORM>');
}
function amendItem(itemno, newquant) {
newItemList = null;
itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == '[') {
thisitem = 1;
itemstart = i+1;
fullstart = i+1;
} else if (fulllist.substring(i,i+1) == ']') {
itemend = i;
itemlist=itemlist+1;
if (itemlist != itemno) {
newItemList = newItemList+'['+fulllist.substring(fullstart, itemend)+']';
} else {
newItemList = newItemList + '['+theitem+'|'+theprice+'|'+newquant+']';
}
} else if (fulllist.substring(i,i+1) == '|') {
if (thisitem==1) theitem = fulllist.substring(itemstart, i);
if (thisitem==2) theprice = fulllist.substring(itemstart, i);
thisitem++;
itemstart=i+1;
}
}
index = document.cookie.indexOf("TheBasket");
document.cookie="TheBasket="+newItemList;
self.location = "bbasket.htm";
}
function removeItem(itemno) {
newItemList = null;
itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == '[') {
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == ']') {
itemend = i;
theitem = fulllist.substring(itemstart, itemend);
itemlist=itemlist+1;
if (itemlist != itemno) {
newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']';
}
}
}
index = document.cookie.indexOf("TheBasket");
document.cookie="TheBasket="+newItemList;
self.location = "bbasket.htm";
}
// clearBasket() - removes all items from the basket
function clearBasket() {
if (confirm('Are you sure you wish to clear the basket')) {
index = document.cookie.indexOf("TheBasket");
document.cookie="TheBasket=.";
self.location = "bbasket.htm";
}
}
</SCRIPT>
<BODY>
<center>
<h2>Check Basket...</h2>
<p>
<!-- all these next few line do is call showItems() which -->
<!-- just creates a table - do what you like with the -->
<!-- presentation around it! -->
<SCRIPT LANGUAGE="JavaScript">
showItems();
</SCRIPT>
<p>
<form>
<input type="button" name="clear" value="Clear Basket" onClick="clearBasket()">
</form>
</center>
</BODY>
</HTML>
