Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding options to a Paypal button 1

Status
Not open for further replies.

Wulfgen

Technical User
Dec 31, 2004
283
US
I am trying to get a flash based button to work with PayPal. I have managed to get flash file to send to PayPal - its very similar to any standard javascript button (for a single item to PayPal) however, there are some other fields in Paypal on0 - os0 that can be used to add other parameters to the button such as color, or size, or whatever - this is generally done as an option menu like this -

<SELECT name=os0>
<OPTION value="none selected" selected> Please Select Color</OPTION>
<OPTION value="Red">Red</OPTION>
<OPTION value="Black">Black</OPTION>
<OPTION value="Green">Green</OPTION>
</SELECT>


Also a field for the amount of items would be: <input size="2" value="1" name="quantity"> (you can see in the code I already have, the quantity set to 1, but would prefer the user to be able to specify the quantity required through an input area on the page.

Mostly all the buttons I have found for Flash deal with the "Buy it Now" feature, which in itself is good , but very, very limited. Is there a way to add an option drop menu to the flash file and an input field so a user can choose a color (using os0) and a size using (on0) with the input field (set the paypal.quantity="";) so then the input number is used other than 1.

This is the code I have on the button on the first frame - this code does work - I have tested it a lot - but I do'nt know how to add the other features.

Code:
on (release) {

//create the LoadVars that will hold our paypal information
var paypal = new LoadVars();
		
//specify the business, amount of the item, shipping, etc.
paypal.cmd="_cart";
paypal.upload="1";
paypal.business="4848";
		
/// Item Information                 
paypal.item_name="Clevis Hook"
paypal.item_number="CLEV_01";
paypal.amount="4.50";
paypal.quantity="1";
paypal.taxable="1";
paypal.undefined_quantity="1"; /// this is for my cart use

//// Shipping Information                
paypal.calc_method="C";
paypal.lot_size="1";
paypal.weight_lbs="0";
paypal.weight_oz="6";
paypal.length="";
paypal.width="";
paypal.height="";
paypal.package="T";
paypal.insure="0";
paypal.on0="Color";
paypal.supp_handling_fee="";
paypal.origin_code="92307";

//// Carrier Special Services                
paypal.addl_handling_ups="1";
paypal.pod_ups="1";
paypal.sig_ups="1";
		
//send our information to PayPal, including all the optional variables we have collected from customer
paypal.send("[URL unfurl="true"]http://www.thisgoestomypaypalcart.com/cart/","cartwindow","POST");[/URL]

}

//this is purely for the animation, nothing more
on (rollOver) {
	gotoAndPlay(2);
}
on (rollOut) {
	gotoAndPlay(11);
}

I've tried adding a dropmenu to my flash file, but it ignores it and uses the code, and ignores the input field - I think I'm doing it wrong somehow - does anyone know how to add these options to what I have here....?

There are other feature I would like to add such as the ability to set a maximum and minimum amount of items to be ordered, but I'll get to them another time - right now, the ability to order a (?) number of items, and the choice of color is imperative - I can then add this to my item details page for ordering purposes...
 
Oops! the action is on the button (movieClip) on the first frame---
 
I would say you are right - but -- I dont know how to do it - my flash experience is with simple things like little animations and jumping from this frame to that, etc etc
 
OK so now I've managed to get a dropdown using a menu list called my_menu with this code on the first frame actions
Code:
/**
 Requires:
  - Menu component in library
  - Button component in library
*/

import mx.controls.Button;
import mx.controls.Menu;

this.createClassObject(Button, "menu_button", 10, {label:"Item Color"});

// Create a menu.
var my_menu:Menu = Menu.createMenu();

// Add some menu items.
my_menu.addMenuItem("Red");
my_menu.addMenuItem("Blue");
my_menu.addMenuItem("Green");
my_menu.addMenuItem("Black");

// Add a change-listener to Menu to detect which menu item is selected.
var menuListener:Object = new Object();
menuListener.change = function(evt_obj:Object) {
 var item_obj:Object = evt_obj.menuItem;
 trace("Item selected: "+item_obj.attributes.label);
};
my_menu.addEventListener("change", menuListener);

// Add a button listener that displays the menu when the button is clicked.
var buttonListener:Object = new Object();
buttonListener.click = function(evt_obj:Object) {
 var my_button:Button = evt_obj.target;
 // Display the menu at the bottom of the button.
 my_menu.show(my_button.x, my_button.y + my_button.height);
};
menu_button.addEventListener("click", buttonListener);

It displays in the (output window) - whatever was chosen from the dropdown -- how can it be set so the variable color choice is passed to the ( paypal.on0=""; ) that way the color choice is sent to paypal as well....
 
OK combobox component...

didnt I mention that I didnt know what I was doing..

is there any solution for this?

Can I pay someone to help me? .... what can I do to get this working :\
 
OK so I added a movie clip called color with a combobox component containing color labels and data -- with an actionscript layer containing this;

Code:
var myListner: object - new Object();
my_menu.addEventListner("change",myListner);

myListner.change - function() {
 BUYNOW_MC.var paypal.Color = set (value);
}

its wrong I know it, but thats as far as I can get with this - I used the var called paypal - see the code above, or should I point it at on0 or is the syntax incorrect
 
In your case you don't need a listener, because you need to capture the selection not on change, but on submit (user can change the selection as many times as she wants, only the final selection on submit counts.)

So the script will be something like:
Code:
// Your submit button script
on (release) {
...
paypal.on0 = [i]pathToYourComboBoxInstance[/i].selectedItem.label;
...
}

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top