By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,528 Members | 1,345 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,528 IT Pros & Developers. It's quick & easy.

Adobe LiveCycle Designer scripting problems

P: 3
Using Adobe LiveCycle Designer, I can't get the script below to work using "formcalc" (a type of Javascript). I use this to calculate shipping costs for
car club items by their weight in a pdf form.

I'm only able to get the correct postage for the weights in lines 3,5 and 7 below. If I select an item that weighs between 0.11 and 0.25, the form calculates it as 2.25 instead of 1.90. Also, if the item weighs 2.51 or more,
it only calculates it as 7.00 instead of 9.00.
Expand|Select|Wrap|Line Numbers
  1.                 if        (ShpWt >= 0.01 <= 0.10) then 
  2.              PostageSH = 1.90
  3.         elseif  (ShpWt >= 0.11 <= 0.25) then 
  4.              PostageS = 2.25
  5.         elseif  (ShpWt>= 0.26 <= 0.75) then
  6.               PostageSH = 4.00
  7.         elseif  (ShpWt > 0.76 <= 2.50) then
  8.             PostageSH = 7.00
  9.         elseif  (ShpWt >= 2.51) then
  10.             PostageSH = 9.00
  11.         endif
  12.  
Please suggest any script changes that will calculate the postage as illustrated.

Thanks in advance,

Mike
Mar 4 '10 #1

✓ answered by gits

according to the FormCalc-reference a correct if-statement with a logical AND should look like:

Expand|Select|Wrap|Line Numbers
  1. if ( ShpWt >= 0.01 & ShpWt <= 0.10 ) then
  2.     ...
  3. elseif ...
  4.  
kind regards

Share this Question
Share on Google+
5 Replies


P: 86
elseif, then and endif don't exist in javascript. Also you forgot the logical OR operator (||) in your if statements and the second part of your if statements doesn't make sense unless you restate the variable you're comparing (in your case, ShpWt).
Mar 5 '10 #2

gits
Expert Mod 5K+
P: 5,390
according to the FormCalc-reference a correct if-statement with a logical AND should look like:

Expand|Select|Wrap|Line Numbers
  1. if ( ShpWt >= 0.01 & ShpWt <= 0.10 ) then
  2.     ...
  3. elseif ...
  4.  
kind regards
Mar 5 '10 #3

P: 3
Thank you for posting the sample FormCalc script reference. That was just the bit of information I needed to get my form to work properly.
Mar 8 '10 #4

P: 3
For anyone else having a similar question regarding FormCalc, here is the final scripting that worked for me:

Expand|Select|Wrap|Line Numbers
  1.     if ( ShpWt == 0 ) then
  2.         PostageSH = 0.00 
  3.     elseif ( ShpWt >= 0.01 & ShpWt <= 0.10 ) then 
  4.           PostageSH = 1.90 
  5.        elseif ( ShpWt >= 0.11 & ShpWt <= 0.25 ) then  
  6.                                   PostageSH = 2.25 
  7.                 elseif ( ShpWt >= 0.26 & ShpWt <= 0.75 ) then 
  8.                                   PostageSH = 4.00      
  9.     elseif ( ShpWt >= 0.76 & ShpWt <= 2.50 ) then 
  10.                                   PostageSH = 7.00 
  11.     elseif ( ShpWt >= 2.51 ) then 
  12.                                  PostageSH = 9.00 
  13.         elseif ( ShpWt == 0 ) then
  14.                    PostageSH = 0.00 
  15.     endif
Mar 8 '10 #5

gits
Expert Mod 5K+
P: 5,390
Thank you for posting the sample FormCalc script reference. That was just the bit of information I needed to get my form to work properly.
no problem ... even when it was no JavaScript question :) ... glad to hear that you got it working now :)

kind regards
Mar 8 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.