Make sure you read the multiple prices howto first:
www.crosstec.org/forums/15-usage/5303-pa...multiple-prices.html
If you want to calculate prices based on a multiplier/selection, use the code below for your PayPalSelect element.
In the element's options (advanced tab in QuickMode) scroll to the action script section and check "change", then select "custom".
In the codebox, paste the code below.
Note the comments that start with // in the code
Very important is that you enter the prices and taxes corresponding to the PayPalSelect values!
The first element in your PayPalSelect should contain a "please choose" message and not contain any prices.
function ff_PayPalSelect_action(element, action)
{
switch (action) {
case 'change':
if(element.selectedIndex > 0)
{
// price|tax corresponding to the PayPalSelect values
var prices = ['60|3', '100|5'];
// name of the select or textfield that holds the multipliers
var howmanyName = 'howmany';
var howmany = ff_getElementByName(howmanyName).options[ ff_getElementByName(howmanyName).selectedIndex ].value;
// or use this if you use a textfield for the multiplier instead of a select, in that case, comment the line above and uncomment below
// var howmany = ff_getElementByName(howmanyName).value;
// calulations and re-assignment of prices and taxes
var val = prices[ element.selectedIndex - 1 ];
var splitted = val.split('|');
var result = Number( splitted[0] ) * Number( howmany );
var taxes = Number( splitted[1] ) * Number( howmany );
var selector = element.options[ element.selectedIndex ].value.split('|');
element.options[ element.selectedIndex ].value = selector[0] + '|' + selector[1] + '|' + result + '|' + taxes;
}
break;
default:;
} // switch
} // ff_PayPalSelect_action
Tip:
If someone is selecting the amount AFTER he selected from the PayPalSelect, make sure the PayPalSelect is set back to its initial state. This will make sure that the correct price is calculated.
This can be done with this action code for the amount selection (onchange as well):
function ff_ELEMENTNAME_action(element, action)
{
switch (action) {
case 'change':
// setting back PayPalSelect to initial state
ff_getElementByName('PayPalSelect').selectedIndex = 0;
break;
}
}