2 Replies Latest reply on Oct 22, 2010 4:24 PM by heywang3

    how to make a variable:

    heywang3

      I am trying to figure out how to make a variable:

       

      Ex.  I have two fields  feildA  and fieldB

       

      I want fieldA to be dependant on fieldB

       

      if  fieldB is  1  then fieldA is 25

       

       

      These are all the other variables

      1 = 25

      2 = 30

      3 = 40

      4 = 50

      5 = 65

      6 = 75

      7 = 85

      8 = 95

      9 = 105

      10 =115

       

      Thanks!!  CJ

        • 1. Re: how to make a variable:
          George_Johnson MVP & Adobe Community Professional

          One way is to set up field A as a calculated field, using a script like the following:

           

          // Calculate script for field A

          (function () {

           

              // Set up object to associate values
              var vals = {
                  1: 25,
                  2: 30,
                  3: 40,
                  4: 50,
                  5: 65,
                  6: 75,
                  7: 85,
                  8: 95,
                  9: 105,
                  10: 115
              };

           

              // Get value of field B

              var v = getField("fieldB").value;

           

              // Set this field's value based on the value of field B

              if (typeof vals[v] !== "undefined") {
                  event.value = vals[v];
              } else {

                  // If corresponding value is not present, blank this field
                  event.value = "";
              }

           

          })();

           

           

          Replace "fieldB" in the code with the actual name of the field you're using.

           

          You could also use similar code in the Validate event of field B to set the value of field A.

          • 2. Re: how to make a variable:
            heywang3 Level 1

            Works perfectly!!!!

             

             

            Thankyou so much!

             

            I amazed how powerful Acrobat is!

             

            CJ