2 Replies Latest reply on May 17, 2012 1:21 PM by schock080

    Need Help Writing a Calculation Script Using a Checkbox

    schock080

      Hello,

       

      I am new to Adobe X Standard and Javascript.  I have all other parts of my fillable change order form completed except the tax calculation.  I have the following fields:

      Text Field = SUBTOTAL

      Text Field = TAX

      Checkbox = Exempt

       

      I would like the calculation in the TAX field to be as follows:

      If the checkbox = false then SUBTOTAL * .05, else SUBTOTAL = 0. 

       

      It really doesn't seem that complex but learning javascript on the fly is apparently above my skill level.  I would greatly appreciate someone's help in getting this initial calculation working.  I greatly appreciate your time.  Thank you.

        • 1. Re: Need Help Writing a Calculation Script Using a Checkbox
          George_Johnson MVP & Adobe Community Professional

          Your description is a bit confusing to me. Do you want to calculate the value of the TAX field? In the last bit of pseudocode, you seem to be setting SUBTOTAL to 0. Do you want the tax to be the SUBTOTAL value times 0.05 if not exempt and 0 if exempt? If so, the custom calculate script of the TAX field can be:

           

          event.value = getField("Exempt").value === "Off" ? +getField("SUBTOTAL").value * 0.05 : 0;

           

          This is equivalent to:

           

          if (getField("Exempt").value === "Off") {

              event.value = +getField("SUBTOTAL").value * 0.05;

          } else {

              event.value = 0;

          }

          • 2. Re: Need Help Writing a Calculation Script Using a Checkbox
            schock080 Level 1

            Hello George,

             

            You were correct in what I needed.  I apologize for the confusion.  Too many hours trying to figure it out

             

            Your solution worked perfectly.  Thank you so much for your prompt and accurate response.  You are a sanity saver.