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

Simply Divide two feild

JessyKing79
Registered: Oct 28 2008
Posts: 2
Answered

Hi friends,

I begin with Acribat and i need to build a calcul sheet. I created three fields, in the first we can enter a number and the seconde too and the third one give us the result of the content of one and two.
easy with sum(+) or Product (X) but what I need to do if I want that the result of feild3 equal feild1 devide by feild2.

I just need to divide the two feild.

Thank you!

My Product Information:
Acrobat Pro 8.1.2, Windows
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi JessyKing79,

This thread should help you out-

http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=14379

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
A problem with using the Simplified Field Notation method is dealing with the case of division by zero, which is what will happen if the field for the denominator is blank or otherwise evaluates to zero. To deal with this, you need to use JavaScript, which allows you to test the value of the denominator and deal with it. For example:

// Get the field values, as numbersvar v1 = +getField("numerator").value;var v2 = +getField("demoninator").value; // Set the value of this fieldif (v2 !== 0) {// Perform the divisionevent.value = v1 / v2;} else {// Set this field to nothing (blank) if denominator is zero// You may want something else hereevent.value = "";}

or equivalently:

var v1 = +getField("numerator").value;var v2 = +getField("demoninator").value; event.value = (v2 !== 0) ? (v1 / v2) : "";

This code assumes the input fields have a numeric format type. You would replace "numerator" and "demoninator" in the code above with the names of your fields.

George