3 Replies Latest reply on Nov 18, 2013 6:39 PM by CarsonC

    Calculation based on radio button

    J-Howie

      Any help here would be appreciated. I know enough Javascript to get me in trouble and that's it.

       

      I have a form with two radio buttons ("progress" and "final") under one group called "billing". Below this I have several calculation fields.

       

      When "progress" is selected, the field "undefined_7" should use the formula (undefined_6) * .10

       

      If "final" is checked, the same field should be set to zero.

       

      Using Arobat X Pro.

       

      Thanks in advance!

        • 1. Re: Calculation based on radio button
          George_Johnson MVP & Adobe Community Professional

          Assuming the export values (aka Button Value, Radio Button Choice) for the two radio buttons are "progress" and "final", the custom calculation script could look like:

           

          // Custom Calculate script

          (function () {

           

              // Get the field values

              var v1 = getField("billing").valueAsString;

              var v2 = getField("undefined_6").value;

           

              switch (v1) {

              case "progress" :

                  event.value = v2 / 10;

                  break;

              case "final" :

                  event.value = 0;

                  break;

              default :  // Neither radio button is selected (v1 === "Off") which may not ever happen

                  event.value = "";

              }

           

          })();

          • 2. Re: Calculation based on radio button
            J-Howie Level 1

            Worked like a charm!!!! Thanks.

            • 3. Re: Calculation based on radio button
              CarsonC

              I have a similar question. Creating an interactive form in Acrobat X Pro. I have a group of radio buttons called CCsurcharge representing a credit card surcharge to be added to an order. The value MC (button 1) is calculated like this: (Price1+Price2+Price3)*.004 and Visa (button 2) is (Price1+Price2+Price3)*.15  When selected, the value of the radio button needs to populate a text field at the end called SurchargeSelect. Any help with the javascript is much appreciated. Not only the custom caculation script, but also where do I enter the value for each radio button?