Adobe LiveCycle Designer scripting problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • spitfiregt6
    New Member
    • Mar 2010
    • 3

    Adobe LiveCycle Designer scripting problems

    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.
    Code:
                    if        (ShpWt >= 0.01 <= 0.10) then 
     			PostageSH = 1.90
    		elseif  (ShpWt >= 0.11 <= 0.25) then 
     			PostageS = 2.25
    		elseif  (ShpWt>= 0.26 <= 0.75) then
      			PostageSH = 4.00
    		elseif  (ShpWt > 0.76 <= 2.50) then
    			PostageSH = 7.00
    		elseif  (ShpWt >= 2.51) then
    			PostageSH = 9.00
    		endif
    Please suggest any script changes that will calculate the postage as illustrated.

    Thanks in advance,

    Mike
    Last edited by gits; Mar 5 '10, 10:24 AM. Reason: added code tags
  • larztheloser
    New Member
    • Jan 2010
    • 86

    #2
    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).

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5390

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

      Code:
      if ( ShpWt >= 0.01 & ShpWt <= 0.10 ) then
          ...
      elseif ...
      kind regards

      Comment

      • spitfiregt6
        New Member
        • Mar 2010
        • 3

        #4
        Adobe LiveCycle Designer scripting problems

        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.

        Comment

        • spitfiregt6
          New Member
          • Mar 2010
          • 3

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

          Code:
          	if ( ShpWt == 0 ) then
          		PostageSH = 0.00 
          	elseif ( ShpWt >= 0.01 & ShpWt <= 0.10 ) then 
            		PostageSH = 1.90 
             	elseif ( ShpWt >= 0.11 & ShpWt <= 0.25 ) then  
                        	                PostageSH = 2.25 
                          elseif ( ShpWt >= 0.26 & ShpWt <= 0.75 ) then 
                        	                PostageSH = 4.00      
          	elseif ( ShpWt >= 0.76 & ShpWt <= 2.50 ) then 
                        	                PostageSH = 7.00 
          	elseif ( ShpWt >= 2.51 ) then 
                        	               PostageSH = 9.00 
                  elseif ( ShpWt == 0 ) then
          	               PostageSH = 0.00 
          	endif
          Last edited by Dormilich; Mar 8 '10, 05:37 AM. Reason: Please use [code] tags when posting code

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            Originally posted by spitfiregt6
            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

            Comment

            Working...