)Hi Stefko,
I was trying
and trying,
and i succeeded in making two sets of radio's on the Managacart page...
I will share you the code at the end.
What i am trying to accomplish is the following.
On the items page, people can choose from 500 lectures.
(too bad that i cannot use one submit button yet

)
Then on the managecart page people have to choose between
Shipping within europe/outside europe
AND
between MP3
and Tape for the media.
For now the choice of MP3
and Tape function does not do anything yet, but i will use it to calculate additional media costs
and also the
weight... (i hope). At least is has no errors.
Basically i just "borrowed" your code to make a new set of buttons, which are also stored in a cookie. So much for invention!!
I think you mean that you would like to store the radio buttons in the existing cookie.
What is also BOTHERING ME INSANE, is that IE
and Opera behave differently on forms.... GGRRRRR
Anyway..
Here is the Nopcart code :
This goes in the top with the vars
- Code: Select all
//Options for Everyone:
MonetarySymbol = '€ ';
DisplayNotice = true;
DisplayShippingColumn = true;
DisplayShippingRow = true;
TaxRate = 0.000; //set taxable region rate ||
DisplayTaxRow = false;
DisplayWeightRow = false; // Displays total Weight row if set to true ...ET...||
DisplayMediaRow = true; // Displays the Media type choice if cart is not empty ...ET ||
TaxByRegion = false; //leave this at false, UPS Shipping Mod will activate taxable Zone ||
TaxPrompt = 'For tax purposes, please select if you are an Kansas branch of Oasis before continuing';
//Deactivated ||
TaxablePrompt = 'Kansas Branch'; //Deactivated ||
NonTaxablePrompt = 'Other Branches'; //Deactivated ||
MinimumOrder = 0.01;
MinimumOrderPrompt = 'Oops!\n\nWe can not proceed to check out since\nthere is no item in the shopping cart.';
//original syntax - MinimumOrderPrompt = 'Your order is below our minimum order, please order more before
checking out.';
- Code: Select all
//---------------------------------------------------------------------||
// FUNCTION: ManageCart ||
// PARAMETERS: Null ||
// RETURNS: Product Table Written to Document ||
// PURPOSE: Draws current cart product table on HTML page ||
// EXTRAS ADDED IN: Code to enable UPS mod. ||
//---------------------------------------------------------------------||
function ManageCart( ) {
var iNumberOrdered = 0; //Number of products ordered
var fTotal = 0; //Total cost of order
var fTax = 0; //Tax amount
var fWeight = 0; //Weight
var fShipping = 0; //Shipping amount
var fLectures = 0; //Nr of lectures in cookie/cart ...ET... ||
var strTotal = ""; //Total cost formatted as money
var strTax = ""; //Total tax formatted as money
var strShipping = ""; //Total shipping formatted as money
var strOutput = ""; //String to be written to page
var bDisplay = true; //Whether to write string to the page (here for programmers)
iNumberOrdered = GetCookie("NumberOrdered");
if ( iNumberOrdered == null )
iNumberOrdered = 0;
LocationSelected = GetCookie("ZoneSelected");
if (LocationSelected == null) LocationSelected = 0; // Code to use Europe as default checked if customer goes to
Checkout with an empty Cart ||
if ( bDisplay )
strOutput = "<TABLE CLASS=\"nopcart\"><TR>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strILabel+"</B></TD>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strDLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strQLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strPLabel+"</B></TD>" +
(DisplayShippingColumn?"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strSLabel+"</B></TD>":"") +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strRLabel+"</B></TD></TR>";
if ( iNumberOrdered == 0 ) {
strOutput += "<TR><TD COLSPAN=6 CLASS=\"nopentry\"><CENTER><BR><B>Your cart is
empty</B><BR><BR></CENTER></TD></TR>";
}
for ( i = 1; i <= iNumberOrdered; i++ ) {
NewOrder = "Order." + i;
database = "";
database = GetCookie(NewOrder);
Token0 = database.indexOf("|", 0);
Token1 = database.indexOf("|", Token0+1);
Token2 = database.indexOf("|", Token1+1);
Token3 = database.indexOf("|", Token2+1);
Token4 = database.indexOf("|", Token3+1);
fields = new Array;
fields[0] = database.substring( 0, Token0 ); // Product ID
fields[1] = database.substring( Token0+1, Token1 ); // Quantity
fields[2] = database.substring( Token1+1, Token2 ); // Price
fields[3] = database.substring( Token2+1, Token3 ); // Product Name/Description
fields[4] = database.substring( Token3+1, Token4 ); // Weight
fields[5] = database.substring( Token4+1, database.length ); //Additional Information
fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
fWeight += (parseInt(fields[1]) * parseFloat(fields[4]) );
fWeight = Math.round(fWeight*100)/100;
var strProductId = fields[0];
if( strProductId[0] != 'n' ) {
fTax += (parseInt(fields[1]) * parseFloat(fields[2]) ) * TaxRate;
}
// Count how many items in the cookie/cart are a lecture||
// ID_NUM begins with a x if it is a lecture ||
//...ET... ||
var strMT = fields[0];
strMT=strMT.charAt(0);
if (strMT == 'x' ) {
fLectures=(fLectures + 1);
}
// END of lecture count
strTotal = moneyFormat(fTotal);
strTax = moneyFormat(fTax);
if ( bDisplay ) {
strOutput += "<TR><TD CLASS=\"nopentry\">" + fields[0] + "</TD>";
if ( fields[5] == "" )
strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + "</TD>";
else
strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + " - <I>"+ fields[5] + "</I></TD>";
strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER><INPUT TYPE=TEXT NAME=Q SIZE=2 VALUE=\"" + fields[1] + "\"
onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";
if ( DisplayShippingColumn ) {
if ( parseFloat(fields[4]) > 0 )
strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>"+ fields[4] + " lbs" + "/ea</TD>";
else
strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>N/A</TD>";
}
strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER><input type=button value=\" "+strRButton+" \"
onClick=\"RemoveFromCart("+i+")\" class=\"nopbutton\"></TD></TR>";
}
if ( AppendItemNumToOutput ) {
strFooter = i;
} else {
strFooter = "";
}
if ( HiddenFieldsToCheckout ) {
strOutput += "<input type=hidden name=\"" + OutputItemId + strFooter + "\" value=\"" + fields[0] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemQuantity + strFooter + "\" value=\"" + fields[1] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemPrice + strFooter + "\" value=\"" + fields[2] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemName + strFooter + "\" value=\"" + fields[3] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemWeight + strFooter + "\" value=\"" + fields[4] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">";
}
}
if ( bDisplay ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=5><B>"+strSUB+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + strTotal + "</B></TD>";
strOutput += "</TR>";
// Show the Media selection row ...ET... ||
if ((DisplayMediaRow) && ( iNumberOrdered != 0 )) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=1><B>MEDIA TYPE</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=5>";
strOutput += "<input type=radio name=\"MEDIA\" value=\"0" + "\" onClick=\"MediaCalc(this.value)\">";
strOutput += "MP3";
strOutput += "<BR><input type=radio name=\"MEDIA\" value=\"1" + "\" onClick=\"MediaCalc(this.value)\">";
strOutput += "Tape";
strOutput += "</TD>";
strOutput += "</TR>";
document.write(strOutput);
strOutput = "";
}
// END - Show the media selection row ||
// Determine the value of the radiobuttons for MEDIA TYPE ||
Media = GetCookie("MediaType");
if (Media != null) {
var cMedia = document.getElementsByName('MEDIA');
for (var iCtr = 0; iCtr < cMedia.length; iCtr++) {
if (cMedia[iCtr].value == Media) cMedia[iCtr].checked = true;
}
}
if (Media == 0) MediaLabel = "MP3";
if (Media == 1) MediaLabel = "Tape";
if ((DisplayMediaRow) && ( iNumberOrdered != 0 )) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=5><B>MEDIA COSTS (" + MediaLabel + ")</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + strShipping + "</B></TD>";
strOutput += "</TR>";
}
// Displays the shipping matrix and sets the value for each zone ||
if (( DisplayShippingRow ) && ( iNumberOrdered != 0)) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=1><B>"+"SHIPPING<BR>ZONE"+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=5>";
strOutput += "<input type=radio name=\"ZONE\" value=\"0" + "\" onClick=\"ComputeShipping(this.value,
"+fWeight+")\">";
strOutput += "Zone 1 - Europe";
strOutput += "<BR><input type=radio name=\"ZONE\" value=\"1" + "\" onClick=\"ComputeShipping(this.value,
"+fWeight+")\">";
strOutput += "Zone 2 - Outside Europe";
strOutput += "</TD>";
strOutput += "</TR>";
document.write(strOutput);
strOutput = "";
// END - Displays the shipping matrix and sets the value for each zone ||
LocationSelected = GetCookie("ZoneSelected");
//if (LocationSelected == null) LocationSelected = 0; // Code to use Local Area as default checked, but not
needed because want null selected at this time ||
//if (LocationSelected != null) document.all.ZONE[LocationSelected].checked = true;
if (LocationSelected != null) {
var cLocations = document.getElementsByName('ZONE');
for (var iCtr = 0; iCtr < cLocations.length; iCtr++) {
if (cLocations[iCtr].value == LocationSelected) cLocations[iCtr].checked = true;
}
}
if (LocationSelected == 0) LocationLabel = "Europe";
if (LocationSelected == 1) LocationLabel = "Outside Europe";
if (fWeight == 0) fShipping = 0;
else fShipping = ComputeShipping(LocationSelected, fWeight);
strShipping = moneyFormat(fShipping);
// ...ET...||
if ( DisplayWeightRow ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=5><B>"+strWTOT+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + fWeight + " lbs" + "</B></TD>";
}
// END ||
// Display the Shipping location row, and the costs ||
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=5><B>" + strSHIP + " " + LocationLabel + "</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + strShipping + "</B></TD>";
strOutput += "</TR>";
}
if (LocationSelected != 0) //sets tax to 0.00 for all areas except 0 ||
fTax = 0.00;
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=5><B>"+strTOT+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + moneyFormat((fTotal +
fShipping + fTax)) + "</B></TD>";
strOutput += "</TR>";
strOutput += "</TABLE>";
if ( HiddenFieldsToCheckout ) {
strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strTotal + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + strShipping +
"\">";
strOutput += "<input type=hidden name=\""+OutputOrderTax+"\" value=\""+ MonetarySymbol + strTax + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\" value=\""+ MonetarySymbol + moneyFormat((fTotal +
fShipping + fTax)) + "\">";
}
}
g_TotalCost = (fTotal + fShipping + fTax);
document.write(strOutput);
document.close();
}
//---------------------------------------------------------------------||
// FUNCTION: MediaCalc ||
// PARAMETERS: Type of Media ||
// RETURNS: Amount of shippingcost / weight of order ||
// PURPOSE: Compute Additional media costs for MP3 and/or tape ||
//---------------------------------------------------------------------||
function MediaCalc(Zone) {
LocationValue = GetCookie("MediaType");
if (LocationValue != Zone) {
SetCookie("MediaType", Zone, null, "/");
location.href=location.href;
}
}
//---------------------------------------------------------------------||
// FUNCTION: ComputeShipping ||
// PARAMETERS: ||
// RETURNS: ||
// PURPOSE: Compute shipping cost due to total weight ||
//---------------------------------------------------------------------||
function ComputeShipping(Zone, TotWeight) {
LocationValue = GetCookie("ZoneSelected");
if (LocationValue != Zone) {
SetCookie("ZoneSelected", Zone, null, "/");
location.href=location.href;
}
if (TotWeight == 0) return 0.00;
if (LocationValue == 0 ) {
if (TotWeight <= 1) return 0.00;
if ((TotWeight <= 500) && (TotWeight > 1)) return (0.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
}
if (LocationValue == 1 ) {
if (TotWeight <= 1) return 8.39;
if ((TotWeight <= 500) && (TotWeight > 1)) return (8.39 + (0.15 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
}
if (LocationValue == 2 ) {
if (TotWeight <= 1) return 8.50;
if ((TotWeight <= 500) && (TotWeight > 1)) return (8.50 + (0.15 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
}
if (LocationValue == 3 ) {
if (TotWeight <= 1) return 8.74;
if ((TotWeight <= 500) && (TotWeight > 1)) return (8.74 + (0.20 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
}
if (LocationValue == 4 ) {
if (TotWeight <= 1) return 8.82;
if ((TotWeight <= 500) && (TotWeight > 1)) return (8.82 + (0.25 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
}
if (LocationValue == 5 ) {
if (TotWeight <= 1) return 9.02;
if ((TotWeight <= 500) && (TotWeight > 1)) return (9.02 + (0.30 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
}
if (LocationValue == 6 ) {
if (TotWeight <= 1) return 9.07;
if ((TotWeight <= 500) && (TotWeight > 1)) return (9.07 + (0.45 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
}
if (LocationValue == 7 ) {
if (TotWeight <= 1) return 9.18;
if ((TotWeight <= 500) && (TotWeight > 1)) return (9.18 + (0.60 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
}
if (LocationValue == 8 ) {
if (TotWeight <= 500) return 20.00;
if ((TotWeight <= 10000) && (TotWeight > 500)) return (20.00 + (6.50 * Math.ceil(parseFloat((TotWeight - 500) /
500))));
}
if (LocationValue == 8 ) {
if (TotWeight <= 500) return 22.00;
if ((TotWeight <= 10000) && (TotWeight > 500)) return (22.00 + (8.00 * Math.ceil(parseFloat((TotWeight - 500) /
500))));
}
}
- Code: Select all