4 Replies Latest reply on Jul 13, 2015 7:34 AM by ashh.allen

    How to do I perform a conditional "or" calculation in PDF?

    ashh.allen

      I am trying to create a calculation that allows my customers to calculate their cost. (Sounds simple...but I am new to JavaScript so I am struggling to fix it)

       

      Objective: I want the formula to calculate the customer's total price based on their membership status plus any add-ons. So the total will either reflect a "NonMember" price with add-ons OR a "Member" price with add-ons.

       

      Booth prices:

      NonMember = $900

      Member = $750

       

      Add-ons:

      Booth Corner= $90

      Booth Extensions= $95

       

      here is what I have:

       

      (function () {

       

          var v1 = ( +getField("Booth_NonMember").value * 900 )  + ( +getField("Booth_Corner").value * 90 )  + ( +getField("Booth_Extensions").value * 95 );

          var v2 = ( +getField("Booth_Member").value * 750 )  + ( +getField("Booth_Corner").value * 90 )  + ( +getField("Booth_Extensions").value * 95 );

       

          var v3 = ( v1 || v2 );

       

       

          event.value = v3;

       

      })();

       

      The problem is, when I enter text in the field for the Member price and then add text in the add-on fields it negates the Member price all together.

                So if I say: I want 1 "Member" Booth ($750) with 1 "Booth Corner" ($90) and 1 "Booth Extensions" ($95) the formula tells me that the total is $185 when it should be $935.

       

       

      am I missing something?