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

Calculations

spolen
Registered: Nov 4 2008
Posts: 15
Answered

I am trying to create a calcuation for a discount on a price sheet and am having difficulty getting this to work. I put percentage in the format tab and use 2 decimals, and it shows a huge number percentage, instead of what I put in.

Example:

There are three fields (text 1) the first is the list price of our product, which is a set property of $99,000. I want to give the customer a 12% discount (text 2), which in the third (text 3) would give the customer the price he would pay with the discount.

I have tried several times to get this to work, including text 3 adding the text 2 multiplication x text 2 = text 3, but with no success.

I am not an expert, but can usually figure out these forms, but am stumped. Do I need to write a script for this? It seems fairly simple but for the life of me, I can't get it.

Thanks for any help...

Sue

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Can you clarify what the "text 2" field is for? Is it supposed to calculate 12% of the price, or contain the value 12, or 12% (0.12)?

Are you trying to use one of the built-in calculation options, or do you want to create a custom calculation script?

George
spolen
Registered: Nov 4 2008
Posts: 15
Hi George,

12% of the price, so it calculates the total amount the customer would pay for the unit. As it stands now, I am only able to get the total of the discount (300.00), now if I put in .88 in the field then I get the correct price, but we don't want it shown that way.

Appreciate your help!

Sue
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
I'm sorry, I don't think I asked the right question. See if the following makes sense:


Text 1: List price of an item, in dollars/cents (ex. $99,000.00)

Text 2: A percentage discount (number between 0 and 100), (ex. 12, display as 12%)

Text 3: Text 1 - discount, in dollars/cents (ex. $87,120.00)


If this isn't what you want, can you lay out an example using the same format I just did?

George
spolen
Registered: Nov 4 2008
Posts: 15
Hi Again,

Yes this is what I want exactly. But I as I said in my previous email, it gives me the dollar discount, not the price the customer would pay with the discount. So if there is a script, or another way to get the same results, I would appreciate your help.

Thanks,

Sue
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
If you want to make it easy to display the % sign, you can set up the "Text2" field to have a Format category of "Percentage", in which case you'll have to enter a number from 0 to 1 to indicate the percentage. For example, to indicate 12%, you'd enter .12, which would then get displayed as "12.00%", though you can specify how many digits to the right of the decimal point you want to display.

The following is a suggestion for a custom calculation script for "Text 3". It assumes that "Text 1" is set up with a numeric format type.

// Get field value of Text 1, as a numbervar v1 = +getField("Text1").value; // If there is a price entered in Text 1...if (v1 != 0) { // Get field value of Text 2, as a numbervar v2 = +getField("Text2").value; // Perform calculation, and set this field's value to the resultevent.value = v1 * (1 - v2); } else { // No price was entered, so blank this fieldevent.value = ""; }

You would have to replace "Text1" and "Text2" in the code above with the actual names of your fields. Post again if this isn't what you want.

George
spolen
Registered: Nov 4 2008
Posts: 15
Hi Again,

My VP of the company wrote the following:

That is almost right, except Text 3 is not the discount, it is the resulting price after the

discount is applied. The actual $$ amount of the discount is not displayed.



Examples:



Text 1 Text 2 Text 3

MSRP Discount Price

$99,000 20% $79,200



Text 1 Text 2 Text 3

MSRP Discount Price

$12,000 40% $7,200



Text 1 Text 2 Text 3

MSRP Discount Price

$190,000 26% $140,600

Hopefully this will help with understanding what he wants in the fields...

Again, thank you for all your help!!

Sue
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
The custom calculation script posted above does just that.

George
spolen
Registered: Nov 4 2008
Posts: 15
Thanks George,

Will try it in the am...and let u know if it worked...appreciate everything...

Sue
spolen
Registered: Nov 4 2008
Posts: 15
Thanks George,

Used the script that you sent and it worked like a charm!!

Appreciate all your help on this...

Sue
garsas
Registered: Apr 6 2011
Posts: 2
Hi, I'm sorry for my bad English. please help me how to write a custom script using the following formula:
text1 = (text2 * 0.3 +27) / 100 * text3
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You can use the simplified field notation as long as your field names used in the calculation do not have any special non-alphanumeric characters or start with a number for the computaion in the text1 field.

You should use more parenthesis to clarify your computation.

You formula is evaluated as:

(((text2 * 0.3) + 27) / 100) * text3

and not:

((text2 * 0.3) + 27) / (100 * text3)

If you want to use the custom calculation, then you need to use the JS objects:

event.value = (((this.getField('text2').value * 0.3) + 27) / 100) * this.getField('text3').value;

George Kaiser

garsas
Registered: Apr 6 2011
Posts: 2
sincerely thank you.