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

Divide by Zero error

eworctap
Registered: Jul 13 2007
Posts: 10
Answered

I apologize if this has been answered, but I can't seem to get this calculation to work and I am brand new to Javascript-ing.

Excel formula is (value a*200000)/value b, where value a is the sum of other fields. Result is a percentage.

My Adobe Acrobat simplified field notation reads in basically the same manner:

Am I creating a divide by zero error with this simplified notation? Do I need some type of custom validation script to ensure that it will work?

Thanks in advance for the help.

eworctap
Acrobat Pro 8.0 user

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
None of the shortcut methods for writing computations supports logical testing, so you will need to write a "Custom calculation script"

// define some variables to look like Excel
var valueA = this.getField("Value A").value;
var valueB = this.getField("Value B").value;

event.value = ""; clear result field
// only perform division if divisor not equal to zero or blank
if (valueB != 0) {
event.value = (valueA * 200000) / valueB;
}

George Kaiser

eworctap
Registered: Jul 13 2007
Posts: 10
I appreciate the quick response...you're making learning from the forums easy for newbies like me.

I pasted your response as a custom calculation script and got this error: missing ; before statement. After pasting the ; in a few hundred spots, it still gives the same error? Help?

Thanks