These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Understanding Conditional Radio Buttons

writtenword
Registered: Apr 14 2007
Posts: 2

Hope you can help. Trying to write a form using Adobe Designer.
 
I have a question in the form requiring a 'yes'/'no' answer. Depending upon which 'radio button' the user selects, a different calculation will extend into a 'subtotal column'.
 
For example:
 
Q: Do you have a low-water flow showerhead?
A: Yes (radio button) No (radio button)
 
What happens as a result of selecting 'yes' is that answer derived from a previous question (number of people in household) is multiplied by another question (average number of minutes in shower per week by all family members) to give a result multiplied by 7.5 (number of litres per minute a water-efficient shower head uses).
 
If they answer 'no', then the result will show a multiplication by 12 instead of 7.5.
 
Ok, now my dilemma is understanding if/else so that I can have a FormCalc script to change the resulting totals dependent upon whether a user selects 'yes' or 'no' using radio buttons to various questions like these.
 
I hope all that makes sense to you.
 
The bottom line is: I'd love some help in simple terms as to how to write the necessary if/else script.
 
Can you help me please?
 
Thanks.

My Product Information:
Acrobat Pro 7.0.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
To do this kind of calculation you'll need to learn some more about JavaScript and LiveCycle forms. But here's something to get you started off.

Radio buttons usually have a numerical value. Zero being unselected. However, this is all under your control from the Object/binding tab for the radio button.

Here's how your calculation might look

var nRslt = StartValue.rawValue;if(MyRadio.rawValue == 1){nRslt = nRslt * 2 + OtherFld.rawValue;}else if(MyRadio.rawValue == 2){nRslt = nRslt + OtherFld.rawValue;}

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

pdftrainer
Expert
Registered: Dec 14 2005
Posts: 180
Thom knows a lot more about JavaScript than I do. Personally, I would use FormCalc triggered by a change event on the radio button.

FormCalc uses spreadsheet-type formulas so it is pretty easy to use. See the FormCalc reference or Designer help for examples.

Basicall, a Yes would trigger a calculation like "Totalfield * 7.5" A no would be "TotalField * 12."

A certified expert on Adobe Acrobat, Carl Young is an Adobe Acrobat and LiveCycle Designer trainer and consultant based in Phoenix. He is the producer of the [link=http://www.pdfconference.com/]PDF Conference[/link].