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

how to calculate field if checkbox is selected?

jazminecat
Registered: Jun 11 2007
Posts: 2

Hi - I'm totally green on writing scripts in adobe, but I've been looking and haven't found a way to do this yet.

I have a form where my end users check boxes to indicate if they had a reimbursable meal for that mealtime. So there's breakfast, lunch, and dinner checkboxes for 5 different days.

I need to set up a calculation that will only return a value if the box is checked.

For example, if the checkbox for BreakfastDay1 is checked, I need my Breakfast1Total field to return the value of 25% times the value in the field GSA Rate ( GSARate x .25).

If BreakfastDay1 is not checked, the value remains at 0 or empty. Note that GSA rate is a field the user fills in - it is not a static value.

I have no clue how to do if...then statements in Adobe or javascript, but if someone could throw me in the right direction, I might be able to muddle through.

Thanks in advance.

lkassuba
ExpertTeam
Registered: Jun 28 2007
Posts: 3636
Thom Parker has a Javascript tutorial on calculations that you might find useful for this at:
http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/form_calculations/

Lori Kassuba is an AUC Expert and Community Manager for AcrobatUsers.com.

acpouser
Registered: May 28 2009
Posts: 2
I am having almost the exact same issue, however the link to the javascript tutorial is dead. Is the tutorial located somewhere else now? Thank You
nixopax
Registered: Feb 6 2009
Posts: 105
Ah yes, the site has been redesigned recently. Here's the up to date tutorial: http://www.acrobatusers.com/tutorials/2006/form_calculations
acpouser
Registered: May 28 2009
Posts: 2
Great, got the form, but it seems to deal with acroforms more than Designer. Ultimately I created a hidden field that stored the data I needed to mulitply based on a true value in a checkbox. However I have found that if a user makes a mistake and un-checks the box, the calculation's output remains. Anyone know of a way to code it so that the value resets to $0.00? Here is what I have (Javascript) in the change of my checkbox:

if ( CheckBox1.rawValue == true )
{
BRATE1.rawValue = "6";
}

then I have a decimal field that contains the following (FormCalc) in the calculate field:

BRATE1 * TOTAL_EMPL

Any Thoughts? Thank You in advance this has been puzzling me for a couple of days now.