2 Replies Latest reply on Aug 11, 2014 6:12 AM by JeremyR

    populate textbox with radio box output

    JeremyR

      I have 2 sets of 5 radio boxes.

       

      Set 1 - CHESTQTY

      option1 - 100

      option2 - 200

      option3 - 300

      option4 - 400

      option5 - 500

       

      Set 2 - BACKQTY

      option1 - 1100

      option2 - 1200

      option3 - 1300

      option4 - 1400

      option5 - 1500

       

      Basically I'm making an order form. When a user selects any option from the CHESTQTY radio box set, I need to output a specific number to a TOTAL box. The total is always $35.00 for any option selected from CHESTQTY.

       

      But, they also have an option of also selecting from the BACKQTY radio box set. They are required to select at least a CHESTQTY but are not required to select a BACKQTY. But if they do select a BACKQTY also, I need to add an additional $85.00 to the previous $35.00.

       

      I'm kind of new to Javascript, but a total rookie when it comes to Javascripting in Acrobat. I've searched the web forever and cannot find anything like this.

       

      What it comes down to is this:

       

      CHESTQTY is required. Adds $35.00 to a text box if any of the options are selected.

      BACKQTY is optional, but if selected, also needs to add $85.00 to the previous $35.00.

       

      Can anyone help with this?

        • 1. Re: populate textbox with radio box output
          George_Johnson MVP & Adobe Community Professional

          If I understand what you're trying to achieve, the custom calculation script for the text field could be:

           

          // Custom calculation script for text field

          (function () {

           

              // Get the field values

              var v1 = getField("CHESTQTY").value;

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

           

              // Create a variable for the sum

              var sum = 0;

           

              // Add 35 to the sum if any of the radio buttons is selected

              if (v1 !== "Off") sum += 35;

           

              // Add 85 to the sum if any of the other radio buttons is selected

              if (v2 !== "Off") sum += 85;

           

              // Set this field's value to the sum

              event.value = sum;

           

          })();

          • 2. Re: populate textbox with radio box output
            JeremyR Level 1

            Thank you!! That worked perfectly.