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

Why is this not working?

JJayzon1
Registered: Mar 2 2009
Posts: 9
Answered

Background I have 30 card amount fields, then I have a subtotal , Per Card Fee, and a Shipping Charge Field. I am trying to get the Shipping Charge field to count the number of amount fields that have an amount entered and if there are less than 25 amounts entered then the shipping charge should be “10” and if there are more than 25 I want the field blank. I also want the field blank when all of the amount fields are empty.

I was able to get the Per Card Fee if statement to work correctly. The Per Card Fee is 3.95 per card and the field should be blank if the amount fields are empty.

Here is the formula I was using for the shipping charge. I’m sure there is a better formula maybe a java script, however I do not know jave at all. PS I have not included all 30 Card Amounts

if (Count(Card_Amount_1,Card_Amount_2,Card_Amount_3,… < 25 ) then
10
else
""
endif

Here is the working per card fee formula.

if ( Count(Card_Amount_1,Card_Amount_2,Card_Amount_3,…) > 0 ) then
Count(Card_Amount_1,Card_Amount_2,Card_Amount_3,…) * 3.95
else
""
endif

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You can make the calculations a whole lot easier by giving the Card Amount fields all the same name, such as "Card_Amount". It also looks like your missing a closing parenthese in the code that isn't working.

Then your calculation code would be
if (Count(Card_Amount[*]) < 25 ) then10else""endif

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

JJayzon1
Registered: Mar 2 2009
Posts: 9
Hey thomp,

Thanks for the tip of naming all the fields the same name it makes everything so much easer. The formula that you gave me works correctly however, I need the Shipping Charge field to stay blank when all the card amount fields are blank. Currently the Shipping charge shows 10 until 25 amount fields are filled which is how the formula is written. I am looking for a formula that states if card amount is less than 25 but greater than 0 then show a value of 10. Is this possible?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Sure, this is easy.
var nAmount = Count(Card_Amount[*]if( (nAmount< 25 ) And (nAmount> 0 ))then10else""endif

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

JJayzon1
Registered: Mar 2 2009
Posts: 9
You are awsome thanks