I am creating a form which calculates a total based on options selected on radio buttons.

However, the sets / groups of radio buttons have different values which depend on other radio buttons.I am guessing it would need to be some kind of an "if" statement?

Any help or advice would be greatly appreciated,thank you so much

The calculation basically needs to be :

Code:

If "Section A" is selected, then the value of radiobutton1 is 50;
radiobutton2 is 60;
radiobutton3 is 70;
"Grandtotal" is 50+60+70 = 180
----- If "Section B" is selected, then the value of radiobutton1 is 100;
radiobutton2 is 120;
radiobutton3 is 130;
"Grandtotal" is 100+120+130 = 350

So far I have the following calculation script which works fine to add up the options IF no section is specified

Ok, so how to we get things happening? We need to set up an event handler for the change event on those radio buttons.Rather than setting up a bunch of event handlers, I've opted to watch the "change" event on the form, this waywe have only one event handler and we can just work out what the target was to know whether we need to do something.

Of course in my HTML example, I've set the first items to checked (not required, but can be handy) - if you're also doing this, you might want to call setValue() at the end to make sure the initial value is set.Step 5 - finishing up

Thank you so much for your detailed reply with explanations. I really appreciate your help.I am trying to implement what you have given me, however am slightly confused (my apologies for my ignorance) - how could I "adapt" this for the use in a PDF form instead of for an html form?

how could I "adapt" this for the use in a PDF form instead of for an html form?

Ah yes of course that is an excellent point. The big difference between the HTML and PDF version is how you interact with elements like form fields, since PDFs don't have a DOM like HTML pages do.

The main bits you'll have to change in my example are the way you reference the fields (and get/set their values I assume) and the event listener to watch for form changes. Other than that I don't think there is much else that needs to change.

Luckily Adobe have a [fairly comprehensive API document that can help you out (plus a few [URL="http://www.adobe.com/devnet/acrobat/javascript.html"]other JavaScript related things](http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf))