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

Calculations

billh098
Registered: Jun 6 2009
Posts: 47
Answered

Hey again,
Well I almost have this working but I am just missing something and can't figure out what it is.

Here is my problem!

I have 5 fields that I am trying to get to do calculations between.

First is a field called A. The settings for this field are set to Number and is manually entered. (this is for square feet).

Second field is called AP (for adjusted percentage) and settins is set to number with decimal point at 2 and vaule is set to 0. (this is for manually entering in a discount percentage ie .10)

Third field is called B (for sales price) that is also manually entered. Settings for this field are set to number.

Fourth field is called ASP1 (for adjusted sales price) Settings for this field are set to number and custom calculation script is:

// total purchase
var a = this.getField("B").value;
// discount rate of total purchase
var b = this.getField("AP").value;
// compute discount amount
var fDiscount = a * b;
// compute total puchase less discount, net purchase price
event.value = a - fDiscount;

The fifth field is called D (for Price per square foot) The settings for this field are set to number and the custom calculation script is:

// clear the field or other action as needed
event.value = '';
var dASP1 = this.getField('ASP1').value;
var dA = this.getField('A').value;
// make sure divisor is not zero or not a number and dividend is not a number
if( dA != 0 & !(isNaN(dA)) ) {
// perform the division
event.value = dASP1 / dA;
}

Ok when you manually enter in square foot number in A and also enter in a sales price in B it should give me the adjusted sales price in ASP1 and a price per square foot in D. If I change any of the nimbers it should re do the correct calculation.

Everything works fine but field D (price per square foot) It keeps coming up with the wrong number.
I have looked and looked and can't seem to find what it is that I am missing.

Can you see what it is that I am missing?
Bill

My Product Information:
Acrobat Pro 8.1.2, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Have you checked the computational order of the fields?

If the result is the expected result for the most recent prior values, then your field calculation order is wrong.

George Kaiser

billh098
Registered: Jun 6 2009
Posts: 47
Thanks,
I tried a couple of different field orders but it did not work. The first one I had looked correct but obviously is not? Do you see what field calculation is wrong?
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
OK, let us take this really slowly!

Answer the following question with 'Yes' or 'No'!

Is the result you are obtaining from the previous data entrires?

George Kaiser

billh098
Registered: Jun 6 2009
Posts: 47
If you are referring to the last data entries here on this post then Yes. If not then I do not know what you mean. Sorry this is pretty new to me.
billh098
Registered: Jun 6 2009
Posts: 47
If anyone knows the answer to this problem I would sure appreciate it.
Bill
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Acrobat 8 has introduced 'dynamic' menu items, so as one selects a 'sticky' menu item the menu bar options can change. This happens with the 'Forms' option.

You have to select from Acrobat's menu bar "Forms => Edit Form in Acrobat". Then select again from the menu bar "Forms => Edit Fields => Edit Form Calculation Order". You should now have popup window displayed. The fields or your form are executed from the top listed item first to the bottom listed last. You will have to move the fields using the buttons to the right "up" or "down" until you have the correct order for your all of your form fields.If you can not work that out, then you can create one script to perform all the calculations and populate all the form fields in the correct order.

George Kaiser

billh098
Registered: Jun 6 2009
Posts: 47
That did it! I did not know about the calculation order. Now SO much makes sense on alot of stuff.
Thanks so much again.
Bill