2 Replies Latest reply on Jan 20, 2011 11:38 AM by maxwyss

    Auto populate blank text fields with n.a from a button or on print out.

    AcrobatUser1123

      This seems straight forward but I cannot find an existing questions on this topic.

       

      I would like to add a form function that will fill any blank text fields with n.a. I do not want to use the default field value as I think it will cause confusion and cannot be applied for text fields formatted for dates. Is it possible to run a script that can do this? It would be OK if the action was triggered from a button or print activity after the rest of the form has been completed.

       

      Any thoughts would be appreciated.

       

      Thanks

        • 1. Re: Auto populate blank text fields with n.a from a button or on print out.
          try67 MVP & Adobe Community Professional

          You can write a simple code that will loop other all of the fields in the document and fill the empty ones with "N.A.".

          Use the method getNthFieldName in conjunction with the numFields property of the Document object to get an array of all of the fields.

          • 2. Re: Auto populate blank text fields with n.a from a button or on print out.
            maxwyss Level 4

            The question is whether your form is used only for filling out on screen (and not as a level 0 form, being printed out and filled out manually).

             

            If so, why not make the default value of the concerned fields to be "n/a" (or whatever you want to name them). That would relieve you from any validating before printing.

             

            Otherwise, you could maintain a list of field names which should get the n/a value if empty. This list would be an array.

             

            Your code in the willPrint event (if you want to have it reliably) would then look like this:

             

            for (var i = 0 ; i < nafieldarray.length ; i++) {

            if (this.getField(nafieldarray[i]).value == this.getField(nafieldarray[i]).defaultValue) {

            this.getField(nafieldarray[i].value = "n/a") ;

            }

            }

             

            HTH.

             

            Max Wyss.