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

Need help with JavaScript for a Sales Tax form

SG
Registered: Nov 10 2007
Posts: 5

Hello everyone,

First let me say I know nothing about JavaScript at all. I am so green at this you could confuse me with that little green insurance lizard :>

Anyway here is what I'm try to do in Acrobat 8.

I have a form that you enter the total Sales Tax in the first Text Box. That is carried down to where it needs to be multiplied by 4% and then needs to be rounded.

The Text Boxes are as follows,,,,

"6State General Sales & Use 4" is the last Text Box the total sales tax is carried down to and in "Text6" needs the total of "6State General Sales & Use 4" multiplied by 4% and rounded two spaces.

Hope I've explained this right and any help is much appreciated,

All the best,
SG

SG
Registered: Nov 10 2007
Posts: 5
Problem Solved....

Seems I had to change the name "6State General Sales & Use 4" to "Text8"
Then using SFN is was as simple as adding the code (Text8 * .0400)
Thanks to a downloadable PDF file about writing JavaScripts by Ted Padova I was able to find and fix my problem.

All the best,
SG
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
It sounds like you are using the "Simplified Field Notation" for writing your script. This field names used by this field does not support special characters in the field names nor does this field support any type of looping or logical control statements like the "for" or "if" statements nor does it support special formatting commands or use functions.

If you want to keep your field names you would have to write a "Custom calculation script" and write out the complete JavaScript code and not have Acrobat generate the code behind the scenes.

For the "6State General Sales & Use 4" field, you could code:event.value = this.getField("Text6").value * 0.04;

And format the field to be a number with 2 decimal places. The calculation might be more, but Acrobat will round the display. If you need the computed value to be 2 decimal places you would have to write additional JavaScript to round the value to the appropriate number of places.

George Kaiser

SG
Registered: Nov 10 2007
Posts: 5
Hi Gkaiseril,

Thanks for responding and you are correct and I did use Simplified Field Notation. I tried the Custom calculation script but I guess I left out something because I never could get it to work. No big deal though as long as it's working it's doesn't matter to me. I have an Excel Spreadsheet setup to do this and I've checked hundreds of Totals between the PDF & Excel sheet and they both give the same answer each time. So it appears the PDF is working correctly at least so far in my testing.Thanks again my friend and all the best,
SG