6 Replies Latest reply on Mar 22, 2011 9:53 AM by gkaiseril

    Selecting spawned fields

    MadMich Level 1

      Say I have a form which has a button that hides a field named "Field"

       

      when i spawn a new page using…

      this.spawnPageFromTemplate ("newPage") //create a new page
      this.pageNum = this.numPages - 1; //move to the new page

      i get a field called "P1.newPage.Field"

       

      This is a basic example but how do i code the button to hide "P1.newPage.Field"?

      this what I thought would do it…

       

      var i = this.pageNum++
      var f = this.getField(String(this.pageNum),"text", i); //name new field
          f.value = String(i+1);
      f.display = display.hidden

       

      Thanks in advance

        • 1. Re: Selecting spawned fields
          try67 MVP & Adobe Community Professional

          The pattern of the spawned fields is: "P"+page number+"."+template name+"."+field name

          By the way, getField() only takes one parameter.

          • 2. Re: Selecting spawned fields
            MadMich Level 1

            Sorry you've lost me there!

             

            At the moment when I spawn a new page the spawned button is scripted to find "Field" only so therefore can't function.

             

            How do i incorporate "P1.newPage.Field" into my spawned button script so it can function?

             

            I have a lot of these fields to sort and appreciate the time you have taken.

            • 3. Re: Selecting spawned fields
              MadMich Level 1

              Sorry you've lost me there!

               

              At the moment when I spawn a new page the spawned button is scripted to find "Field" only so therefore can't function.

               

              How do i incorporate "P1.newPage.Field" into my spawned button script so it can function?

               

               

              I have a lot of these fields to sort and appreciate the time you have taken.

              • 4. Re: Selecting spawned fields
                try67 MVP & Adobe Community Professional

                Instead of trying to access the original field name ("Field" in your case), you now need to construct the name of

                the spawned field, using the pattern I described. Then you could use getField() to retrieve it.

                • 5. Re: Selecting spawned fields
                  MadMich Level 1

                  My template page has around 30 various fields set up. Are you saying that i can rename these fields when i spawn the template using your pattern?

                  • 6. Re: Selecting spawned fields
                    gkaiseril MVP & Adobe Community Professional

                    Look at A Lesson in Templates for Adobe Acrobat by Dave Wright to see how the field names are created. I have found that making two copies of the form, one with out the additional name prefixes (used for the template) and the the other with the field names prefixed with the "P0.TemplateName.". This will keep the 1st page with the same name structuring of as the spawned pages.By carefully crafting the scripts for the form to include a variable for the page number (zero based), it is possible to create calculations that work on a given page, and by accessing the number of pages of the entire form, one can also access a field on any given page by the naming convention which is consistent across all of the displayed form pages. When you spawn a page you know the page number of the new page, if you use a variable then you can can supply the correct page number for that field.

                    1 person found this helpful