All this simple JavaScript (JS) plugin does is to accept the value fields from selects and concatenate them into various PayPal fields depending on the name suffix. These value fields may have different descriptions, price modifying information, item numbers or shipping costs in them.
We start with the output of the PayPal button factory and make a few changes. Then the JS processes the FORM and adjusts the fields. <view source> on this page to see what was done.
Copy the JS from this example and paste it into your page within the <head> section, like is done on this page. Only one copy of the JS is needed for any page - no matter how many buy buttons you have.
If you want a view-cart button somewhere on the page you must copy the view FORM from my page and insert it into your page right after the <body... statement, like I have done here. You will need to change the business value, or course.
Go into every FORM that can place an order and add these things - (you should look at this source to understand what I am saying).
Elements to hold all the base values. You must have base values, else repeated changes just keep adding to original values. You may need some or all of these base fields: basedes, baseitn, baseamt, baseon0, baseos0, baseon1, baseos1.
Elements to hold the final values of variables - one for each base value. item_name, item_number, amount, on0, os0, on1, os1.
An Event Handler (EH) to the FORM element (onsubmit) which processes the selects, like I have done on this page.
An optional text field named tot where the item cost is displayed if you include an EH on all the items that modify price. In this case the base price of the tot variable must be the default settings of the items before any price adjustment is made. Right-click to see how I did it on this page.
Selects so the user can input his values.
There are single-token, and three-token flags that may be used in the value field of the options.
"#" to indicate that an item number follows.
"@" to indicate that a price value follows.
"+" to indicate that a price increment follows.
"%" to indicate that a price percent change follows.
"s1=" indicates a shipping value follows.
"'s2=" indicates a shipping2 value follows.
It is not obvious, but negative amounts are allowed. The first characters are a flag value (has special significance to parsing), but after that you may input any valid nunmber. -1 is a valid number, so "+-1.50" is perfectly legal.
Here is an example of what you may put into the value of an option field of a select...
Setting shipping is a little tricky, in that if you use it in any value field of a select, then you must use it in every value field, even if it is set to zero. Also, don't forget to include the hidden shipping and shipping2 fields in your FORM so they can be stuffed.
Contact me concerning this article at
paypalhelper@aol.com.
Mention "simple script" in your note.
Individual help starting at $25.00 for simple JS solutions.