2 Replies Latest reply on Nov 20, 2014 9:04 AM by chrome46

    Using dynamic referencing in PDF Form with Checkboxes

    chrome46

      I have created a checklist that contains approx 60-70 steps. About 20 of them are to have a checkbox that fills an adjacent field with the date, and another with the user name. I have already got this functioning as a stand alone process.

      aaa = checkbox

      aaadate = field for date

      aaaname = field for name

      [code]

      function test() {

      var one = this.getField("aaa");

      var two = this.getField("aaadate");

      if (one.value == 'Yes') {

      if (two.value == "") {

           this.getField("aaadate").value = util.printd("dd-mmm-yy",new Date());

           this.getField("aaaname").value = identity.name;

      }} else if (one.value == 'Off') {

           this.getField("aaadate").value = "";

           this.getField("aaaname").value = "";

      }}

      [/code]

       

      I do not want to write a piece of code for each checkbox so I am trying to figure out how to use dynamic referencing so that when i check on a checkbox, the code takes the checked checkboxes' name (aaa) and is able to determine the two other fields name by appending/concatenating (name + "date"  = aaadate)

       

      I have tried various methods and done tremendous research; I'm not sure if I lack the knowledge to incorporate what I've found properly, if I just have been looking in the wrong places for the wrong things. It seems like this should be possible in a PDF form...

       

      Please help

        • 1. Re: Using dynamic referencing in PDF Form with Checkboxes
          try67 MVP & Adobe Community Professional

          You need to inject the part of the field name that changes as a variable. So your code would be something like this:

           

          function test(base) {
              var one = this.getField(base);
              var two = this.getField(base+"date");
              if (one.value == 'Yes') {
                  if (two.value == "") {
                      this.getField(base+"date").value = util.printd("dd-mmm-yy",new Date());
                      this.getField(base+"name").value = identity.name;
                  }
              } else if (one.value == 'Off') {
                  this.getField(base+"date").value = "";
                  this.getField(base+"name").value = "";
              }
          }
          

           

          And you would call it like so:

          test("aaa");

          test("bbb");

          etc.

          • 2. Re: Using dynamic referencing in PDF Form with Checkboxes
            chrome46 Level 1

            Thank you so much...I had a hard time getting it to work, then I re-read the entire message and realized I missed calling it properly :/