03/12/2002, 18:25
|
| | | Fecha de Ingreso: noviembre-2002 Ubicación: Rosario
Mensajes: 70
Antigüedad: 22 años, 1 mes Puntos: 0 | |
//----- CONTINUACION....
//---------------------------------------------------------------------||
// FUNCTION: DeleteCookie ||
// PARAMETERS: Cookie name, path, domain ||
// RETURNS: null ||
// PURPOSE: Removes a cookie from users browser. ||
//---------------------------------------------------------------------||
function DeleteCookie (name,path,domain) {
if (GetCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
//---------------------------------------------------------------------||
// FUNCTION: MoneyFormat ||
// PARAMETERS: Number to be formatted ||
// RETURNS: Formatted Number ||
// PURPOSE: Reformats Dollar Amount to #.## format ||
//---------------------------------------------------------------------||
function moneyFormat(input) {
var dollars = Math.floor(input)
var tmp = new String(input)
for (var decimalAt = 0; decimalAt < tmp.length; decimalAt++) {
if (tmp.charAt(decimalAt)==".")
break;
}
var cents = "" + Math.round(input * 100)
cents = cents.substring(cents.length-2, cents.length)
dollars += ((tmp.charAt(decimalAt+2)=="9")&&(cents=="00"))? 1 : 0;
return dollars + "." + cents
}
//---------------------------------------------------------------------||
// FUNCTION: RemoveFromCart ||
// PARAMETERS: Order Number to Remove ||
// RETURNS: Null ||
// PURPOSE: Removes an item from a users shopping cart ||
//---------------------------------------------------------------------||
function RemoveFromCart(RemOrder) {
if (confirm("Click 'Ok' to remove this product from your shopping cart.")) {
NumberOrdered = GetCookie("NumberOrdered");
for(i=RemOrder; i < NumberOrdered; i++) {
NewOrder1 = "Order." + (i+1);
NewOrder2 = "Order." + (i);
database = GetCookie(NewOrder1);
SetCookie (NewOrder2, database, null, "/");
}
NewOrder = "Order." + NumberOrdered;
SetCookie ("NumberOrdered", NumberOrdered-1, null, "/");
DeleteCookie(NewOrder, "/");
location.href=location.href;
}
}
//---------------------------------------------------------------------||
// FUNCTION: GetFromCart ||
// PARAMETERS: Null ||
// RETURNS: Product Table Written to Document ||
// PURPOSE: Draws current cart product table on HTML page ||
//---------------------------------------------------------------------||
function GetFromCart() {
NumberOrdered = 0;
Total=0;
TOTotal=0;
TOquantity = " ";
TOprice = " ";
TOid_num = " ";
TOname = " ";
NumberOrdered = GetCookie("NumberOrdered");
whattowrite = "";
for (i = 1; i <= NumberOrdered; i++) {
NewOrder = "Order." + i;
database = "";
database = GetCookie(NewOrder);
Token0 = database.indexOf("|", 0);
Token1 = database.indexOf("|", Token0+1);
Token2 = database.indexOf("|", Token1+1);
fields = new Array;
fields[0] = database.substring( 0, Token0 );
fields[1] = database.substring( Token0+1, Token1 );
fields[2] = database.substring( Token1+1, Token2 );
fields[3] = database.substring( Token2+1, database.length );
Total = Total + (fields[1] * fields[0]);
TOTotal = moneyFormat(Total);
whattowrite += "<tr><td>" + fields[2] + "</td><td><font size=-1>"
+ fields[3] + "</font></td><td>$" + fields[1]
+ "</td><td><input type=text size=2 name=\"QUANTITY_"+ i +"\" value=\""
+ fields[0] + "\"></td>"
+ "<td><input type=button value=\" Remove \" onClick=\"RemoveFromCart("+i+")\"></td>"
+ "<input type=hidden name=\"ID_"+ i +"\" value=\"" + fields[2] + "\">"
+ "<input type=hidden name=\"NAME_"+ i +"\" value=\"" + fields[3] + "\">"
+ "<input type=hidden name=\"PRICE_"+ i +"\" value=\"" + fields[1] + "\">";
}
document.write(whattowrite);
document.write("</td></tr><tr><td colspan=2><b>SUBTOTAL</b></td><td>$");
document.write(TOTotal);
document.write("</td><td></td>");
}
//---------------------------------------------------------------------||
// FUNCTION: WriteToForm ||
// PARAMETERS: Null ||
// RETURNS: Product hidden fields Written to Document ||
// PURPOSE: Draws current cart product hidden fields on HTML form ||
//---------------------------------------------------------------------||
function WriteToForm() {
NumberOrdered = 0;
Total=0;
TOTotal=0;
TOquantity = " ";
TOprice = " ";
TOid_num = " ";
TOname = " ";
NumberOrdered = GetCookie("NumberOrdered");
whattowrite = "";
for (i = 1; i <= NumberOrdered; i++) {
NewOrder = "Order." + i;
database = "";
database = GetCookie(NewOrder);
Token0 = database.indexOf("|", 0);
Token1 = database.indexOf("|", Token0+1);
Token2 = database.indexOf("|", Token1+1);
fields = new Array;
fields[0] = database.substring( 0, Token0 );
fields[1] = database.substring( Token0+1, Token1 );
fields[2] = database.substring( Token1+1, Token2 );
fields[3] = database.substring( Token2+1, database.length );
Total = Total + (fields[1] * fields[0]);
TOTotal = moneyFormat(Total);
document.write("<input type=hidden name=\"ID_"+ i +"\" value=\"" + fields[2] + "\">");
document.write("<input type=hidden name=\"NAME_"+ i +"\" value=\"" + fields[3] + "\">");
document.write("<input type=hidden name=\"PRICE_"+ i +"\" value=\"" + fields[1] + "\">");
document.write("<input type=hidden name=\"QUANTITY_"+ i +"\" value=\"" + fields[0] + "\">");
}
}
//================================================== ===================||
// END NOP Design SmartPost Shopping Cart ||
// V.3.0.1 ||
//================================================== ===================||
</SCRIPT>
<NOSCRIPT>
Whoops, we detected that your browser does not have JavaScript, or it is disabled. Our product catalog
requires that you have JavaScript enabled to order products. <a href="http://www.netscape.com">Netscape</a>
and <a href="http://www.microsoft.com/ie">Microsoft</a> offer free browsers which support JavaScript.
If you are using a JavaScript compliant browser and still have problems, make sure you have JavaScript enabled in
your browser's preferences.
</NOSCRIPT>
----- FIN thescript ----- |