4 Replies Latest reply on Apr 21, 2014 10:34 AM by Aman Habib

    Javascript Help Please

    Aman Habib

      I want to be able to have a combo box to automatically populate a field with a certain phrase or number. I dont know javascript and need some help.

       

      For example, in "combo box 1"- Cats, Dogs, Hamsters, Fish

       

      If I chose Cats, "Text1" field should populate "25,000"

      If I chose Dogs, "Text1" field should populate "10,000"

       

      I know this is a simple custom calculation but still need assistance

       

      Thanks

        • 1. Re: Javascript Help Please
          George_Johnson MVP & Adobe Community Professional

          The easiest way is to set the export value of each combo box item to the corresponding numeric value. The calculation simply sets the value of the field to the value of the combo box. In JavaScript, this would be:

           

          event.value = getField("combo box 1").value;

           

           

          If you don't want to set export values fro the combo box items, the custom calculation script could look like:

           

          (function () {

           

              // Object to associate combo box items with numbers

              var oVals = {

                  "Cats" : "25,000",

                  "Dogs" : "10,000",

                  "Birds" : "15,000"

               }

           

              // Set this field value to number associated with item, or blank if missing

              event.value = oVals[getField("combo box 1").value] || "";

           

          })();

          • 2. Re: Javascript Help Please
            Aman Habib Level 1

            Thank you, it worked. Is there anyway to export different values to multiple fields from a single combo box? Would be very helpful?

             

            Thanks again for all the help.

            • 3. Re: Javascript Help Please
              George_Johnson MVP & Adobe Community Professional

              Yes, that would be possible, you'd set have to set things up correctly to do that. If you provide more information, I could probably suggest something specific.

              • 4. Re: Javascript Help Please
                Aman Habib Level 1

                Is it possible for me to set multipule different export values from the different options in the combo box.

                Example: "Combo Box 1" has Andy, Bernadette, Charles, Danny.

                 

                 

                If i choose Andy, I want other values to automatically populate on the page. Ex. Age, Height, Gender.

                The values would be different for Bernadette, Charles and Danny.

                 

                Again I apoligize, I really am lost when it comes to Javascript and appreciate all the help.