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

I'm STUCK on radio button exclustion group

kball
Registered: Nov 3 2010
Posts: 7

I have a group of 6 radio buttons(PerDiemRates) - Their values are set as 1-6 in the binding tab of the group.
 
Each value is associated with a dollar amount. (46.00, 51.00, 56.00, 61.00, 66.00 and 71.00)
 
I then have three check boxes. (Breakfast, Lunch & Dinner)
 
I need the value of a numeric field (one for each checkbox) to populate with a value depending on the radio button selectoni.
 
Example:
 
Radio Button for $46.00 is selected
Then Breakfast checkbox is selected
Value = $7.00
Else if radio button $51.00 is selected
Then Breakfast check box is selcted
Value = $8.00
 
and so on for the other amounts as well as the lunch and dinner check boxes.
 
I have tried putting in script on the Click event, change event, mouse up event as well as calculation in the numeric field.
 
I have scoured this site and google for two days and the most I can get is for the numberic field to show "$0.00"
 
I'm not comprehending what I am reading in the resources online (obviously).
 
I can email you my document (I haven't "prettied" up the last two pages) so you can see that I'm not just asking someone to do this for me. I've got a functioning form but this last bit will make it fool proof for the user.
 
I need a really dumbed down assitance.
 
Please help! I've spent a lot of time on this voucher and I'm proud of what I have been able to accomplish. (Espcially with the help of Niall's website and responses)!
 
Signed ~
Flusterd, Frazzled, Sad
 
Adobe 8 PRo - LiveCycle Designer 8 - Windows
 

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are two things that need to be understood to create a solution.
1) Writing conditional logic for a calculation
2) Acquiring and using Radio buttons on a LiveCycle form.

Which part is the bit you're having difficulty with?

Have you read this article:Conditional Execution


Also, search this site for "Conditional Calculation".


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

kball
Registered: Nov 3 2010
Posts: 7
Yes, I have. I couldn't get it to work. It's all very overwhelming to me.

I've schetched out on paper how I want it too look, but it seems like there's a few ways to go. I don't know what's proper. I did get it to work but not clean like I envisioned....

I'm making it messy with this:

I'm setting the values when the radio button is clicked.

I'm now working on hiding those valued until the user clicks the check box.

switch (this.rawValue)
{
case "1":
var1.value = "7";
var2.value = "11";
var3.value = "23";
break;

case "2":
var1.value = "8";
var2.value = "12";
var3.value = "26";
break;

case "3":
var1.value = "9";
var2.value = "13";
var3.value = "29";
break;

case "4":
var1.value = "10";
var2.value = "15";
var3.value = "31";
break;

case "5":
var1.value = "11";
var2.value = "16";
var3.value = "34";
break;

case "6":
var1.value = "12";
var2.value = "18";
var3.value = "36";
break;

default:
var1.value = null;
var2.value = null;
var3.value = null;
break;
}

form1.execEvent("calculate");


thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ok, There are some simple rules of thumb to follow when scripting a form.

1) The same field value should never be set from scripts in different locations. This will create a conflict.

2) If setting a value depends on a single source, i.e. the setting of a checkbox, then the script should be driven by an event on the source element, such as a check box click event.

3) If setting a value depends on values from multiple sources then the script should be a calculation on the destination element. Since your values depend on two sources, all the code should be in calculation scripts in destination fields. Do not set any values through any other events.

4) It is very easy to create event loops. One event drives another event, when triggers the first event again. It is a very good practice to write code that runs in a single direction.

The last line in the script above is unnecessary. First, the calculation events are called automatically whenever any field changes are made on the form. But the more deadly implication is that you have calculation scripts in the fields of interest. Not good when values are being set from this script.

Also, what is "var1", "Var2" and "Var3"? Are these field names? If so then the field value is "var1.rawValue".

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