2 Replies Latest reply on Aug 19, 2008 10:33 AM by (Nick_Moreno)

    Checking a box next to a name places that name into a text field

    Level 1

      I would like to implement the following in my PDF documents, but I am script-inept. I use Adobe Acrobat 8 Professional and run Windows XP SP2.

      Here is my scenario:
      I have a list of names. Next to these names are check-boxes. When these boxes are checked, I would like for the name to appear in a text box below the names.

      For example, if I check off JIM, SUSAN, and DAN, I would like the text box below to read "JIM, SUSAN, DAN." Conversely, UN-CHECKING would remove their names from the text field.

      Is this possible in Adobe Acrobat? If so, can someone help me with the implementation? Or link me to an appropriate help site?

      I have a basic script that I'm working with (below). I don't know if this is the best way to approach the problem; I've found that un-checking a name does NOT remove it from a list -- it adds it again! I've applied this script to a MouseUp event for the appropriate check-box. Should I put this code somewhere else?

      --begin code--

      this.getField("FIELD_B").value = this.getField ("FIELD_B").value + " SUSAN, ";

      --end code--

      FIELD_B is where the names are being displayed.

        • 1. Re: Checking a box next to a name places that name into a text field
          George_Johnson MVP & Adobe Community Professional
          Set up a document-level JavaScript function like the following:

          function update_names() {

              // Number of names check boxes
              var num_names = 3;

              // Initialize these variables
              var curr_name;
              var s = "";
              var bPrev = false;

              // Loop through check boxes
              for (var i = 0; i < num_names; i++) {

                  // Get the value of the current check box
                  curr_name = getField("cb" + i).value;

                  // Add name if check box is checked
                  if (curr_name != "Off") {

                      // Insert a comma if a name
                      // has been added previously
                      if (bPrev) {
                          s += ", " + curr_name;
                      } else {
                          s += curr_name;

                      // Set flag indicating a name
                      // has been added
                      bPrev = true;


              // Poplate text field with names string
              getField("names").value = s;


          This code is dependent on certain things. First, the check boxes for the names should be named cb0, cb1, cb2...cb10 (or up to your maximum). Be sure to start the numbering at zero and increment by one for each subsequent check box. Also, the export value of each check box should be set to the corresponding name of the person. You have to change the value of the variable "num_names" to match the number of check boxes that you'll have. Finally, the code places the names string that it builds into a text field named "names".

          You can place a call to this function in the Mouse Up event of each check box:


          And that should do it.

          • 2. Re: Checking a box next to a name places that name into a text field
            Level 1

            This code works perfectly. It does exactly what I need it to do.

            Thank you so much!