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

multiple mathematic operations using simplified field notation

Bill1234
Registered: Feb 8 2009
Posts: 10
Answered

Is it possible to multiply two fields, divide the result by a set number and then calculate the square root?
or do you have to be able to use Java script? I am not a programmer!

My Product Information:
Acrobat Pro 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Yes, you'll need to use JavaScript. Here's some code you can use as the custom calculation script for a field that adapt to suit your needs:

// Get the field values, as numbersvar v1 = +getField("Text1").value;var v2 = +getField("Text2").value; // Multiply the two values and a constantvar product = v1 * v2  / 42; // Calculate the square rootvar sr = Math.sqrt(product); // Set the value of this field to the resultevent.value = sr;

This can all be simplified to:

// Get the field values, as numbersvar v1 = +getField("Text1").value;var v2 = +getField("Text2").value; event.value = Math.sqrt(v1 * v2 / 42);

You'd replace "Text1" and "Text2" in the code above with the names of your two fields, and place 42 with the number you want to use.

George