Expand|Select|Wrap|Line Numbers
- quantities[poz] -= itQ;
Expand|Select|Wrap|Line Numbers
- currency_code = "USD";
- init = function(){
- shoppingcart.items = "";
- shoppingcart.amounts = "";
- shoppingcart.quantities = "";
- shoppingcart.total = "0 "+currency_code;
- items = new Array();
- amounts = new Array();
- quantities = new Array();
- }
- addItem = function(itN,itA,itQ){
- if(items.length > 0){
- poz = -1;
- for(i=0;i<items.length;i++){
- if(items[i] == itN){
- poz = i;
- }
- }
- if(poz == -1){
- items.push(itN);
- amounts.push(itA);
- quantities.push(itQ);
- }else{
- quantities[poz] += itQ;
- }
- }else{
- items.push(itN);
- amounts.push(itA);
- quantities.push(itQ);
- }
- shoppingcart.items = "";
- shoppingcart.amounts = "";
- shoppingcart.quantities = "";
- shoppingcart.total = 0;
- for(i=0;i<items.length;i++){
- shoppingcart.items += items[i]+"<br>";
- shoppingcart.amounts += amounts[i]+" "+currency_code+"<br>";
- shoppingcart.quantities += quantities[i]+"<br>";
- shoppingcart.total += amounts[i] * quantities[i];
- }
- shoppingcart.total += " "+currency_code;
- }
- sendToPayPal = function(){
- if(items.length > 0){
- paypal = new LoadVars();
- paypal.cmd = "_cart";
- paypal.upload = "1";
- paypal.no_note = "1";
- paypal.business = "necromanthus@yahoo.com";
- paypal.currency_code = currency_code;
- for (n=0; n<items.length; n++) {
- paypal["item_name_"+(n+1)] = items[n];
- paypal["amount_"+(n+1)] = amounts[n];
- paypal["quantity_"+(n+1)] = quantities[n];
- }
- paypal.send("https://www.paypal.com/cgi-bin/webscr", "_blank", "POST");
- }
- }
- but1.onRelease=function(){
- addItem("Intel Core 2 Duo E6850",270,1);
- }
- but2.onRelease=function(){
- addItem("Intel Core 2 Quad Q6700",550,1);
- }
- but3.onRelease=function(){
- addItem("Intel Core 2 Extreme QX6850",1000,1);
- }
- but4.onRelease=function(){
- addItem("Wordpress Blog",750,1);
- }
- checkout.onRelease=function(){
- sendToPayPal();
- }
- init();
- stop();