5 Replies Latest reply on Aug 27, 2013 9:19 PM by 41globalit

# How to ignore a dropdown field that contains value "N/A"?

Have a client that I have built a simple form for that does basic calculations.  There are 6 dropdowns that all contain N/A, 1, 2, 3.  And at the end a overall average is calculated from these drop downs.  client is wanting to totally ignore any drop downs that contain N/A meaning if N/A is in 2 of the 6 dropdowns then a average should only be calculated on 4 drop downs.   I am just lost on the logic or if statement needed to tell the total field to ignore a certain drop down field if user has selected N/A....

Thanks N Advance for any help!

• ###### 1. Re: How to ignore a dropdown field that contains value "N/A"?

This will require a custom JavaScript for the calculation were one must get the value from each field and test that value for not being "N/A" and then counting and summing the values that are not equal to "N/A".

You cannot use the built in average since this counts all the fields.

// Average non-N/A values;

var aFieldNames = new Array("Value.0", "Value.1", "Value.2", "Value.3", "Value.4");

// counter for non-N/A values;

var nCount = 0;

// variable to sum non-N/A values;

var nSum = 0;

// default value for result if no average computed;

event.value = 0;

// process array of field names;

for(i = 0; i < aFieldNames.length; i++) {

if(this.getField(aFieldNames[i]).valueAsString != "N/A") {

// field does not have a value of "N/A";

nCount++; // increment counter

nSum += Number(this.getField(aFieldNames[i]).value); // add value to sum

} // end value not N/A;

} // end loop processing one field;

// compute the average;

if(nCount != 0) {

// non-zero divisor so we can compute the average;

event.value = nSum / nCount;

}

• ###### 2. Re: How to ignore a dropdown field that contains value "N/A"?

This worked perfect form me!! thanks so much!!  Trying to use same formula in LiveCycle but not working at all.  Does the script have to change in LiveCycle??

• ###### 3. Re: How to ignore a dropdown field that contains value "N/A"?

Yes, the default scripting language is FormCalc and not JavaScript. Even the JavaScript used in LiveCycle  has many differences from the script used in Acrobat.

• ###### 4. Re: How to ignore a dropdown field that contains value "N/A"?

OK Thanks do you know any tutorials or sample links around that could get average calculation in livecycle?

THanks so much

• ###### 5. Re: How to ignore a dropdown field that contains value "N/A"?

Would you happen to know a route to take to allow/configure adjustable text field within adobe acrobat?