4 Replies Latest reply on Mar 15, 2012 5:44 PM by Electryx

# Javascript Help - Conditional Calculation

Hello:

I am trying to figure out how to perform an averaging calculation on a form.  Here's my problem, I've attached a ss:

I have 4 columns, each representing a unit.  In the weekly attendance summary at the bottom, I calculate the attendance percentage for that unit.  The issue is that not all units have a 'Delta' sub-unit and when the Total average is calculated at the bottom right for TRAINING, I don't want to consider units that are not being used.  What I did so far was set Delta's total to 100 if their attended at the top was 0 as that would mean they are not in existence.  Looking for a better way to do this.

Thanks,

-e

• ###### 1. Re: Javascript Help - Conditional Calculation

You just need a different way to indicate that the Delta column does not apply. You could add a check box, allow the fields to be cleared, or some other entry (-, NA, etc). The calculation script could then decide whether to calculate a value or not based on this information.

• ###### 2. Re: Javascript Help - Conditional Calculation

Hi George:

Thanks very much for your answer.  I ended up having to make a couple changes.  Here's what the whole thing looks like:

What I need to figure out how to do is populate the fields under training and roll-call on the left side with calculations based on the selection in R/C or Trg.  So, if I put a person's name in under Alpha and beside their name select AWOL, over on the left, I want it to add 1 in the AWOL row for Alpha.

I have no idea how to get started, although with some pointers I am sure I can figure it out.  I did manage to sort out the problem from the first question I had and I am embarassed at how easy it was in retrospect.  Another unrelated question, is there a way to set it up such that once you have made a selection from the combo box, the arrow to the side disappears?

Thanks again,

-e

• ###### 3. Re: Javascript Help - Conditional Calculation

What you can do is create a custom Calculate script for the AWOL/Alpha field that looks at the value of each of the R/C combo boxes in the ALpha section. counts how many are set to AWOL, and set the field value to this number. You'd do the same sort of thing for the other fields. It shold probbly be made into a function in a document-level script so the code can be reused for the other fields, but this may require some fields to be renamed to optimize it. Without knowing your current field names and export values, it hard to suggest the specific code.

You can't make the down-arrow go away for an active combo box, but it doesn't appear when the document is printed or the field is set to read-only.

• ###### 4. Re: Javascript Help - Conditional Calculation

Hi George:

Here's a screenie showing field names.

The field names for the TRG combobox are: ATT, EXC, UNEXC

Thanks,

-e