All pastes #175 Raw Edit

dumb javascript

public text v1 · immutable
#175 ·published 2004-05-30 04:06 UTC
rendered paste body
showItems in orderform
	  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);
		subtotal = 0;
		//cpr-------
		subtotal_cpr = 0;
		//----------
		subweight = 0;
		document.writeln('<table width="425" cellpadding="2" cellspacing="1" border="0" class="tableborder">');
        document.writeln('<TR><TD BGCOLOR="#CDC6AA"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b>Qty</b></FONT></TD><TD  BGCOLOR="#CDC6AA"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b>Item No.</b></FONT></TD><TD BGCOLOR="#CDC6AA"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b>Item</b></FONT></TD><TD BGCOLOR="#CDC6AA"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b>Price&nbsp;$</b></FONT></TD><td BGCOLOR="#CDC6AA"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b>Amount</b></FONT></td></TR>');
		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));
				
				//cpr
				itemtotal_cpr = 0;
	//-----------------------------------------------------------------------------------	
	// this determines if each item is a newsletter or a cpr		
				if (thenumber != "AS"){
			
			      if (thenumber != "OE"){
				        if (thenumber != "CB"){
						     if (thenumber != "CA"){
							      if (thenumber != "TM"){
								        if (thenumber != "TL"){
										     if (thenumber != "LS"){
											      if (thenumber != "ME"){
												       if (thenumber != "FR"){
													        
			      cpr = "yes";
				                        } else cpr = "no"
							                  } else cpr = "no"
								                   } else cpr = "no" 
												        } else cpr = "no"
														      } else cpr = "no"  
															       } else cpr = "no"
																        } else cpr = "no"
																		     } else cpr = "no"
				                 } else cpr = "no"
				
			//end shipping test
			// start cpr only tax test
			if (cpr != "no"){
			itemtotal_cpr = (eval(theprice*thequantity));
			}
	//----------------------------------------------------------------------------------------------
				temptotal = itemtotal * 100;
				subtotal = subtotal + itemtotal;
				//cpr----------
				subtotal_cpr = subtotal_cpr + itemtotal_cpr;
				//-------------
				weighttotal = 0;
				weighttotal = (eval(theweight*thequantity));
				subweight = subweight + weighttotal;
				itemlist=itemlist+1;
				document.write('<tr><td align=middle BGCOLOR="#EEEAD9"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+thequantity+'</FONT></td>');
				document.writeln('<td BGCOLOR="#EEEAD9"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+thenumber+'</FONT></td><td align=left BGCOLOR="#EEEAD9"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+theitem+'</FONT></td><td align=right BGCOLOR="#EEEAD9"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+theprice+'</FONT></td><td align=right BGCOLOR="#EEEAD9"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+alterError(itemtotal)+'</FONT></td></tr>');
		        document.writeln('<INPUT TYPE="hidden" NAME="itemNumber" VALUE="'+theitem+'" SIZE="40">');
			   //if item is not a newsletter then set shipping to yes --this is prob the l o n g w a y, but then again ive never written alot of javascript so im happy if it works for now.
			   //probably can get rid of this inplace of above.. so this later
			if (thenumber == "AS"){
			shippingCharge = "no";
			    } else if (thenumber == "OE"){
			    shippingCharge = "no";
				   } else if (thenumber == "CB"){
			       shippingCharge = "no";
				       } else if (thenumber == "CB"){
			           shippingCharge = "no";
					   } else {
					    shippingCharge = "yes";
						      }