2 Replies Latest reply on Oct 18, 2010 12:37 PM by StevenLeuck

    Need help with an "IfThenIfNot" Statement

    StevenLeuck

      Every couple years I need some help with a scripting statement and these forums have been incredibly helpful. I was hoping once again someone out there had some familiarity with something I'm trying to write for a form I need to automate:

       

      In Excel Lingo what I'm trying to write would be stated as @if(("Subtotal"+"InvestigativeFee"+"PlanReviewFee")>1000,+100,+(("Subtotal"+"Investigativ eFee"+"PlanReviewFee")*.1))

       

      What I have here is three form fields named Subtotal, InvestigativeFee & PlanReviewFee.  The form in question says that the there is a "technology assessment fee" of 10% on the subtotal of the above mentioned 3 fields but that there is a maximum charge of $100 for this fee.  In Excel the statement I wrote above would have worked (not tested but generally that's the idea).  I was hoping someone conversant in JavaScript could help me with a statement I would need to make this work.

       

      Hope to hear someone,

       

      Gratefully yours,

       

      Steven L in Eugene OR

        • 1. Re: Need help with an "IfThenIfNot" Statement
          George_Johnson MVP & Adobe Community Professional

          Try the following as the assessment fee field's custom Calculate script:

           

          // Custom Calculate script

          (function () {

           

              // Set maximum fee

              var max_taf = 100;

           

              // Get the field values as numbers

              var v1 = +getField("Subtotal").value;
              var v2 = +getField("InvestigativeFee").value;
              var v3 = +getField("PlanReviewFee").value;

           

              // Calculate fee

              var taf = (v1 + v2 + v3)/10;

           

              // Set this field value to calculated fee if less than maximum, otherwise set to maximum

              event.value = (taf < 100) ? taf : max_taf;

           

          })();

          • 2. Re: Need help with an "IfThenIfNot" Statement
            StevenLeuck Level 1

            didn't get a chance until now to try/test your post. Thank you VERY much!  It worked PERFECTLY.  Was exactly what I needed.  Thank you.

             

            Steven Leuck

            Oregon