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

Percentages in javascript

haley
Registered: Jul 15 2010
Posts: 38

I am looking for a simple calculation. I have a total of tax premiums on one line and I would like to do a calculation to obtain 1.25 percent of the amount that will be entered on the previous line. The amount of tax premiums will be different for each institution

Example: Total payable at 1.25% of the previous line

My Product Information:
Acrobat Pro 9.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Multiply it by 0.0125

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

haley
Registered: Jul 15 2010
Posts: 38
try67 wrote:
Multiply it by 0.0125
Thanks but i need to know what the calculation script would be
haley
Registered: Jul 15 2010
Posts: 38
Thanks but I need to know what the calculation script would be
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi haley,

This tutorial should help-

http://www.acrobatusers.com/tutorials/2006/form_calculations

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
JavaScript is an object orientated language, so one needs to establish which object one wants to process and then one can access that object's properties (like value) or use the object's methods (like setFocus).
Assuming using the custom calculation script:
// establish fields to processvar cTotalPremiums = 'TotalPremimsFieldName'; // get the value of the fieldvar nTotalPremiums = this.getField(cTotalPremiums).value; // establish tax rate to usevar nTaxRate = 0.0125; // or value of the field with the tax rate // for this field compute the taxevent.value = nTaxRate * nTotalPremiums;

Depending upon what fields you have and how you named the fields, you might be able to use the other calculation options.

All of the above assumes your form was created using Acrobat and not LiveCycle Designer.

George Kaiser

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Or use the Simple Field Notation option, like so:

TotalPremimsFieldName * 0.0125

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

haley
Registered: Jul 15 2010
Posts: 38
try67 wrote:
Multiply it by 0.0125
This doesn't help me at all

I am trying to calculate 1.25% of teh total taxable to equal the tax payable
haley
Registered: Jul 15 2010
Posts: 38
gkaiseril wrote:
JavaScript is an object orientated language, so one needs to establish which object one wants to process and then one can access that object's properties (like value) or use the object's methods (like setFocus).
Assuming using the custom calculation script:
// establish fields to processvar cTotalPremiums = 'TotalPremimsFieldName'; // get the value of the fieldvar nTotalPremiums = this.getField(cTotalPremiums).value; // establish tax rate to usevar nTaxRate = 0.0125; // or value of the field with the tax rate // for this field compute the taxevent.value = nTaxRate * nTotalPremiums;

Depending upon what fields you have and how you named the fields, you might be able to use the other calculation options.

All of the above assumes your form was created using Acrobat and not LiveCycle Designer.
haley
Registered: Jul 15 2010
Posts: 38
Thanks for the reply - I am still getting error messages when I do the calculation script. The error is still showing that I am missing ;.

I just want to calculate 1.25% of the total tax payable to equal the tax payable. Anything simpler.
haley
Registered: Jul 15 2010
Posts: 38
Dimitri wrote:
Hi haley,This tutorial should help-

http://www.acrobatusers.com/tutorials/2006/form_calculations

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
haley
Registered: Jul 15 2010
Posts: 38
Dimitri wrote:
Hi haley,This tutorial should help-

http://www.acrobatusers.com/tutorials/2006/form_calculations

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi haley,

What is the exact error message? Just writing that "I am missing a ; " is inadequate for gkaiseril or try67's crystal balls to work. They are trying to help you but you aren't helping yourself by telling them their attemps aren't helpful.

Post the exact code you have tried and the exact error message you get from the Console Window when you try running the code. Or share your form at Acrobat.com- if someone happens to have free time to diagnose/develop your form for you they will be better able to help you that way than fruitless back and forth with not enough information to go on. Help them help you.

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
try67
Expert
Registered: Oct 30 2008
Posts: 2398
haley, see Dimitri's response.

And BTW - (1.25% of x) [i]is[/i] the same as (x * 0.0125)

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

haley
Registered: Jul 15 2010
Posts: 38
Sorry about that - but the general webpage that try67 sent to me - I could not find any calculation answers anywhere.

gkaiseril was the best answer that I received except I was getting an error message (missing ; before statement 1: at line 2)

I really didn't want to sound ungreatful because that was not the intention. I am a new adobe 9 pro user and am finding it very difficult in this respect to calculations. All of the codes are very overwhelming as a new user.

I apologize

What I am trying to do is calculate 1.25% of the total taxable to equal the tax payable.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
If you are cutting and pasting the code and need to change the field name, you need to have quotations around the new field name and they need to be matched pairs.

You also need to use a very vanilla text editor, not MS Word.

This calculation is the same as that of computing sales tax on an invoice.

George Kaiser