function showBasket() { 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('
'); document.writeln(''); document.writeln(''); itemlist = 0; for (var i = 0; i <= fulllist.length; i++) { if (fulllist.substring(i,i+1) == '[') { thisitem = 1; itemstart = i+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(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); } else if (fulllist.substring(i,i+1) == '|') { if (thisitem==1) theitem = fulllist.substring(itemstart, i); if (thisitem==2) thecolid = fulllist.substring(itemstart, i); if (thisitem==3) thetype = fulllist.substring(itemstart, i); if (thisitem==4) theprice = fulllist.substring(itemstart, i); thisitem++; itemstart=i+1; } } document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln('
Item Qty. Price Total cost ( $ ) Remove
'+theitem+'
' + thetype+'
$'+theprice+' $'+alterError(itemtotal)+'
Total Cost ( $ ) $'+alterError(totprice)+'  
'); } // alterError - fixes a rounding bug in Netscape 2 function alterError(value) { if (value<=0.99) { newPounds = '0'; } else { newPounds = parseInt(value); } newPence = parseInt((value+.0008 - newPounds)* 100); if (eval(newPence) <= 9) newPence='0'+newPence; newString = newPounds + '.' + newPence; return (newString); } function getVal(field) { var ctrl = eval("document.forms['itemsform']." + field); var idx = ctrl.selectedIndex; var option = ctrl.options[idx]; return option.text; } // buyItem - adds an item to the shooping basket function buyItem(newItem, newColID, newColName, newPrice, newQuantity) { if (newQuantity <= 0) { rc = alert('The quantity input is not correct'); } else { if (confirm('Add '+newQuantity+' x '+newItem+' ' + newColName + ' to basket?')) { index = document.cookie.indexOf("TheBasket"); countbegin = (document.cookie.indexOf("=", index) + 1); countend = document.cookie.indexOf(";", index); if (countend == -1) { countend = document.cookie.length; } document.cookie="TheBasket="+document.cookie.substring(countbegin, countend)+"["+newItem+"|"+newColID+"|"+newColName+"|"+newPrice+"|"+newQuantity+"]"; self.location = self.location; } } } function updateBasket() { 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; newquant = document.updateform["quant"+itemlist].value; removed = document.updateform["remove"+itemlist].checked; if (!removed) { newItemList = newItemList + '['+theitem+'|'+thecolid+'|'+thetype+'|'+theprice+'|'+newquant+']'; } } else if (fulllist.substring(i,i+1) == '|') { if (thisitem==1) theitem = fulllist.substring(itemstart, i); if (thisitem==2) thecolid = fulllist.substring(itemstart, i); if (thisitem==3) thetype = fulllist.substring(itemstart, i); if (thisitem==4) theprice = fulllist.substring(itemstart, i); thisitem++; itemstart=i+1; } } index = document.cookie.indexOf("TheBasket"); document.cookie="TheBasket="+newItemList; self.location = self.location; } // 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 = self.location; } } // goCheckout() function goCheckout() { ordertotal = document.updateform["Goods Total"].value; if (ordertotal<25) { alert('Please note the minimum order value accepted is USD 25'); } else{ if (ordertotal>500) { alert('Please note the maximum order value accepted is USD 500 '); } else{ self.location = "https://247-drugstore.com/products/order_delivery.aspx"; } } }