1 Reply Latest reply on Jul 30, 2009 7:46 AM by gkaiseril

    Auto populate dates throughout a form?

    Danielle_S

      Hello all,

      Sorry if this has been brought up before, but I searched all day and could not find an answer. I have never actually used Javascript, but I assume this is what I need to know to get what I need to work.

       

      I have a PDF that I have made into a form in Adobe Acrobat. It has 5 date fields. I would like the first date field to be a start date. Then based off of that date, I want the date fields below it to cascade down with about 2-3 days between them. So for example the first date would be 7/27 and the person filling out the form would only need to enter that first date. Then the next date down will automatically fill in with the date 3 days later (7/30) and I want to keep this going for the next few slots. Do I need to run a Javascript and if so, where and how? And also is there a way I can have just workdays be factored in, no weekends? (I know excel had that option so I didn't know if the forms did)

      I have many other fields that are to be filled in on this document as well, so take that into consideration.

       

       

      Thank you for any information you may have!

      -Danielle

        • 1. Re: Auto populate dates throughout a form?
          gkaiseril MVP & Adobe Community Professional
          Arobat JavaScript uses JavaScript's date object. This object contains the date 
          and time since the Epoch date in milliseconds, so you will need to do some
          math and conversions to the compute the date and extract the information
          about the computed date.
            
           
           




          Some sample code

          // define some time constants
          var nSec = 1000; // 1000 ms/sec
          var nMin = 60 * nSec; // 60 seconds/minute * (one second)
          var nHr = 60 * nMin; // 60 minutes/hour * (one minute)
          var nDay = 24 * nHr; // 24 hours/day * (one hour)
          var nWeek = 7 * nDay; // 7 days/week * (one day)


          // get the current date time object
          var oCurrDate = new Date();

          // display some information about today
          // formatted date
          var sCurrDate = util.printd('mmm dd, yyyy', oCurrDate);
          // day of the week
          var sCurrDay = util.printd('dddd', oCurrDate);
          // display the data
          // display formatted date
          console.println('Today is: ' + sCurrDate);
          // display day of week
          console.println('The day of the week is: ' + sCurrDay);

          //  add 3 days to current date value
          var nExpDate = oCurrDate.getTime() + (3 * nDay);
          // convert new date value to a date time object
          var oExpDate = new Date(nExpDate);
          // format computed date time object to a readable string
          var sExpDate = util.printd('mmm dd, yyyy', oExpDate);
          // get day of week from the date time object
          var sExpDay = util.printd('dddd', oExpDate);

          // show some information about the computed date
          // display formatted date
          console.println('In three days it will be: ' + sExpDate);
          // display day of week
          console.println('The day of the week will be: ' + sExpDay);