2 Replies Latest reply on Feb 11, 2017 1:31 PM by gkaiseril

    Adobe Acrobat Pro 7 - Fillable Forms - Java Script for List Options.

    emilieb70488021

      Example:

      1. Please Select each applicable option:

      Option 1

      Option 2

      Option 3

      Option 4

      Option 5

      Option 6

       

      2 By holding the CTL key the user selects:

       

      Option 1

      Option 2

      Option 3

      Option 4

      Option 5

      Option 6

       

      Printed/Saved output appears as:

       

      Option 2, Option 4, Option 5.

       

      Can anyone give me the Adobe Javascript to make this happen?

      Thanks in advance!!!!

       

      [Moved from the non-specific Coding Corner to a product-specific forum - moderator]

        • 1. Re: Adobe Acrobat Pro 7 - Fillable Forms - Java Script for List Options.
          try67 MVP & Adobe Community Professional

          Acrobat-specific JavaScript questions should be asked here: JavaScript

          • 2. Re: Adobe Acrobat Pro 7 - Fillable Forms - Java Script for List Options.
            gkaiseril MVP & Adobe Community Professional

            Have you looked at the freely available Acrobat JavaScript Reference?

             

            A combo box can be set to allow multiple or a single selection. One then needs to test the value of the field to see if it is an array or a single item. You can test the type of the value of the combo box to see if it is "string" for a single answer or "object" for multiple selections in an array;

             

            Assuming a combo box field with a name of "Combo Box1" and text field for the result with a name of "Text1", a possible custom calculation script could be:

             

            event.value = "";

            // get combo box field object;

            var oCombo = this.getField("List Box1");

            // test value of combo box;

            if(typeof oCombo.value  == "object")

            {

            var aValues = new Array();

            for(var i = 0; i < oCombo.value.length; i++)

            {

              if(oCombo.value[i] != " " || oCombo.value[i] != "")

              {

               // eliminate single space or null string selections;

               aValues[aValues.length] = oCombo.value[i];

              }

            }

            event.value = aValues.join(",");

            } else {

            if(oCombo.value != " " || oCombo.value != "")

            {

              // eliminate space or null sting seledtions;

              event.value = oCombo.value;

            }

            }

            1 person found this helpful