6 Replies Latest reply on Oct 30, 2011 1:05 PM by jscherrer

# If qty >11, then calculate 10% discount on amount

New to java scripting, I've been looking and need help on the following...

3 fields:

quant subtotal

amount subtotal

discount

If "quant subtotal" is >11, then "discount" =  ("amount subtotal" ) (-10%)

If "quant subtotal" is <=11, then "discount" =  0

• ###### 1. Re: If qty >11, then calculate 10% discount on amount

What kind of form do you have?  Did you build this using LiveCycle Designer? or was it all done in Acrobat?

http://acrobatusers.com/tutorials/conditional-execution

Thom Parker
The source for PDF Scripting Info
pdfscripting.com

The Acrobat JavaScript Reference, Use it Early and Often

Then most important JavaScript Development tool in Acrobat
The Console Window (Video tutorial)
The Console Window(article)

• ###### 2. Re: If qty >11, then calculate 10% discount on amount

Thank you for the quick response. The form is in Acrobat standard.

PS - I've found your articles and video's to be hugely helpful already which is why I know that this is possible!

• ###### 3. Re: If qty >11, then calculate 10% discount on amount

Since its an AcroForm the article provides the correct information.

The solutuion is to create a caculation script in the "discount" field.

var nQuantity = this.getFeild("quant subtotal").value;

if(nQuantity > 11)

event.value = this.getFeild("amount subtotal" ).value * 0.1;

else

event.value = 0;

Thom Parker
The source for PDF Scripting Info
pdfscripting.com

The Acrobat JavaScript Reference, Use it Early and Often

Then most important JavaScript Development tool in Acrobat
The Console Window (Video tutorial)
The Console Window(article)

• ###### 4. Re: If qty >11, then calculate 10% discount on amount

I do this myself all the time...

this.getFeild() should be this.getField()

• ###### 5. Re: If qty >11, then calculate 10% discount on amount

Ha Ha, That whole ie thing gets me all the time.  Thanks for the catch.

• ###### 6. Re: If qty >11, then calculate 10% discount on amount

Thanks so much, yes caught the typo. Also needed to add the negative to the 0.1.

Seems to be working! Thanks

var nQuantity = this.getField("quant subtotal").value;

if(nQuantity > 11)

event.value = this.getField("amount subtotal" ).value * -0.1;

else

event.value = 0;