What program are you using to create the form.
Your code looks similar LIveCycle's FormCalc script and that has a different syntax.
I am working with Acrobat Pro to create the form.
The above is basically the thought process not actual code
Depending upon where the code is located, the form should automatically update with a change in the selection of another field.
What do expect to happen if another type of payment like check, cash, or PayPal is used how will the surcharge be handled?
Is there a default selection and will you allow not having a selection like occurs when a form is cleared?
Since all the values for any selection is unique and does not appear that any 2 items will have the same value, why not use the "Optional Value" for the drop down field? It hat is done then one only needs to multiply the values using any of the 3 calculation options.
You can use this code as the custom calculation script for "subcharge":
var card = this.getField("card").valueAsString; var amount = Number(this.getField("amount").valueAsString); if (card=="1") event.value = amount*0.01; else if (card=="2") event.value = amount*0.03; else if (card=="3") event.value = amount*0.05; else event.value = "";
Thanks for the replies and Try67 your a legend! The code works a treat. My problem was I hadn't used valueAsString.