6 Replies Latest reply on Jun 21, 2016 7:50 AM by jlw825

    Checkbox Adds to Total

    jlw825 Level 1

      Hey There,

       

      Would anyone happen to know if there is a script so that when a box is checked, it adds the correlating price to the total?

       

      Screen Shot 2016-06-21 at 8.48.08 AM.png

       

      Thanks in advance!

       

      JW

        • 1. Re: Checkbox Adds to Total
          gkaiseril MVP & Adobe Community Professional

          There are at least 2 ways to do that.

           

          1. Use the check box's export value to populate the fee field.

           

          2. Sum the export values of the check  boxes.

          • 2. Re: Checkbox Adds to Total
            try67 MVP & Adobe Community Professional

            Sure. It can look something like this:

             

            var total = 0;
            if (this.getField("CheckBox1").value!="Off") total+=12;
            if (this.getField("CheckBox2").value!="Off") total+=12;
            if (this.getField("CheckBox3").value!="Off") total+=7; // etc.
            event.value = total;
            
            • 3. Re: Checkbox Adds to Total
              jlw825 Level 1

              Where do I put that then, in each fee box? And since it's total+12 and what not, what happens if I want to manually change the fee? Then it won't add that?

              • 4. Re: Checkbox Adds to Total
                jlw825 Level 1

                The problem is that the fees need to be in there so the customer can see what it does cost. The fee can't be 0, all fees must be displayed at all times.

                • 5. Re: Checkbox Adds to Total
                  try67 MVP & Adobe Community Professional

                  You use the code I provided as the custom calculation script of the total field.

                  I had assumed that the prices are fixed. If they are in fact dynamic and you have a text field for each price then you can use something like this:

                  var total = 0;
                  if (this.getField("CheckBox1").value!="Off") total+=Number(this.getField("Price1").value);
                  if (this.getField("CheckBox2").value!="Off") total+=Number(this.getField("Price2").value);
                  if (this.getField("CheckBox3").value!="Off") total+=Number(this.getField("Price3").value); // etc.
                  event.value = total;
                  
                  1 person found this helpful
                  • 6. Re: Checkbox Adds to Total
                    jlw825 Level 1

                    It works! Thanks for the help! Just trying to work my way around this learning curve, so I appreciate it.