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

Simple subtract + calculate discount % (based on checked option)

Joe Doe
Registered: Jul 26 2010
Posts: 3
Answered

(Sorry if this has been covered in the past guys, the forum search isn't working for me!!)
 
I need 2 'simple' solutions.
 
First off, on the top of my form there's an option to check either 12%, 15% or 18% discount.
Then people can select a bunch of products, these amounts add up to a SUBTOTAL (so far so good),
and just below it SHOULD show the % of discount in $ based on the subtotal amount.
 
Now I can't figure out how to have it calculate + show either 12, 15 or 18% of the subtotal..??
I'm not even sure what the best way is to check the discount percentage on top and then have it show up on the bottom..
(hope I'm being clear)
  
Secondly, this should be easy.. I need to SUBTRACT the DISCOUNT $ from the SUBTOTAL to show up in the TOTAL field
on the complete bottom of my form. I've been attempting a script like: ((DISCOUNT) - (SUBTOTAL))
but it won't work...
  
My math skills are seriously ridiculous by the way :-(
Thanks so much in advance for any help, I'm pretty lost here, and the pressure is high to get this form out.... :-((
 
-Joe-

My Product Information:
Acrobat Pro 9.0, Macintosh
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
First, you can use the 'Format' tab to display the Percentage sign and Currency symbols without affecting the computational amount of the displayed field.

The trick to using the discount selected in a calculation is having the 3 check boxes all named the same and then setting the 'Export Value' for each check box to the decimal value for the discount being applied. For 12% use 0.12, for 15% use 0.15 and for 18% use 0.18. This is the value of the check box field. If no check box is selected the export value will be the character string "Off"

With that done, you can create a field to show the amount of the discount being given. Use a text field and set the format to a number and select the appropriate currency symbol. For the calculation, you an select the 'Value is the ___ of the following fields:' and select the field for the check box and the subtotal fields. This method of calculation will treat the string value of "Off" as zero.

Calculating the "TOTAL" will be more complicated, since the discount amount is specified as a positive number and there is no option for subtraction. But you can use the 'Simplified field notation' and enter the following code:
SUBTOTAL - DISCOUNT
You might want to look over How to do (not so simple) form calculations by Thom Parker for other ideas.

George Kaiser

Joe Doe
Registered: Jul 26 2010
Posts: 3
Thanks a lot gkaiseril!

I'm going to try your solution, but in the meantime let me explain what I did so far (before reading your post)..

I have the 3 radio buttons with the same name (DISCOUNT%) but different button value (0.12, 0.15, 0.18),
so far so good...

Then, I've (tried to) make a a script in the DISCOUNT$ field saying:

—————————————

if
this.getField("DISCOUNT%") = 0.12;
then
this.getField("DISCOUNT$") = (SUBTOTAL * 0.12);
else if
this.getField("DISCOUNT%") = 0.15;
then
this.getField("DISCOUNT$") = (SUBTOTAL * 0.15);
else
this.getField("DISCOUNT$") = (SUBTOTAL * 0.18);

—————————————

Am I getting anywhere with this, or am I waaaay off..??

Thanks again!!
Joe Doe
Registered: Jul 26 2010
Posts: 3
OK GREAT I GOT IT WORKING!!

I was making oit way too difficult and wasting lots of time with the script, stubborn as I am!!
Just before going completely nuts I went back to your post and actually followed your instructions,
made PERFECT SENSE and all is fine now... fjew, was I getting sweaty!!

Thanks so much again George!!


Ps. just for my knowledge, would a script like I was messing with have been an option at all??

This is where I gave up:

--------
if(this.getField("DISCOUNT%") = 0.12)
then this.getField("DISCOUNT$") = (SUBTOTAL * 0.12);
else if(this.getField("DISCOUNT%") = 0.15)
then
this.getField("DISCOUNT$") = (SUBTOTAL * 0.15);
else
this.getField("DISCOUNT$") = (SUBTOTAL * 0.18);
--------

I'm just wondering if I was making any sense at all..
Although your solution was so much more sensible & logical!!
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
I would have just checked to see if the value of the check box is 'Off'. If it is "Off", the the discount rate is zero. The rest is just computing the value.
// get the discount ratevar discount = this.getField("DISCOUNT%").value;// if none has been selected then discount is zeroif (discount == "Off") discount = 0;// compute discountevent.value = this.getField("SUBTOTAL").value * discount;

George Kaiser