4 Replies Latest reply on Aug 12, 2011 11:32 AM by TUAdmin

    Form Text Field auto-date fill upon Check-box "yes"

    TUAdmin

      In know the auto-date topic has come up before, and I've read several postings on the subject, but haven't seen my particular question answered.  My appologies if this is a repeat.

       

      I would like to have an auto-date fill in a Text Box with Today's Date in reaction to a Check-Box (or radio button?) which is clicked "yes".  The check-box/auto-date will be used to track when documents are received (Date Received), so that date should be saved and not change when the form opens or closes.

       

      Can someone help me with this?  Is this even possible?

      I'm using AAPro 9.  I am pretty new to using script.  So if you can tell me where I should be putting the script and what I should name my field(s) to correspond to the script parameters, that would be very helpful.  Thanks!

        • 1. Re: Form Text Field auto-date fill upon Check-box "yes"
          gkaiseril MVP & Adobe Community Professional

          You should be able to see how to do this with an if statement and the code for the auto date. You should also allow for the unchecking of the check box.

           

          You could use the following JavaScript for a "Mouse UP" action and an unformatted, read only text field named "DateField":

           

          if(event.target.value == "Off") {

          // field unchecked - clear the text field

          this.getField("DateField').value = "";

          } else {

          // field checked - fill in the current date

          this.getField("DateField').value = util.printd("mmm d, yyyy", new Date());

          }

          1 person found this helpful
          • 2. Re: Form Text Field auto-date fill upon Check-box "yes"
            TUAdmin Level 1

            Hi GKaiseril.  Thank you, but I don't quite understand.

             

            I'm in the Check-Box Properties > Action tab and I see Mouse Up trigger.  I selected Run a JavaScript and copied in the script you provided, but I get an error (SyntaxError: unterminated string literal 5: at line 6) underneath this.getField("DateField').value = "";

             

            Am I puting your script in the right place?  Should it be in the Text Box properties?

             

            Please advise.

            • 3. Re: Form Text Field auto-date fill upon Check-box "yes"
              gkaiseril MVP & Adobe Community Professional

              You may need to remove the smart quotations and use the very plan quotation marks.

              1 person found this helpful
              • 4. Re: Form Text Field auto-date fill upon Check-box "yes"
                TUAdmin Level 1

                Thank you!  Altering the quotation marks did it.

                I exchanged the single quotation mark (') for the double (") after DateField.

                 

                So it reads:   this.getField("DateField").value =""  (double quotation mark after DateField)

                 

                instead of:      this.getField("DateField').value ="" (single quotation mark after DateField)

                 

                Thanks again for your help!  Cheers.