Skip to main content
shelbyanderson
Participant
June 23, 2017
Question

Sequential Autofill dates from original date entry

  • June 23, 2017
  • 2 replies
  • 1129 views

I need a script that does exactly what the post linked here  describes, but I need to it work for INDD rather than Acrobat. Here is a copy of the question and solution from that original post:

I have 75 weeks of boxes that I need to auto-fill with sequential dates a week

a part based on whatever is entered in the very first date box.  From the example I show here I am filling in the first box for Week1 (box name: Week01) with 12/01/2015.  I want all the boxes running to the right of that to automatically fill in dates in one week increments based off the date in that first box.  The form field are named, Week02, Week03, Week04, etc....

I am no JavaScript wizard but after making several basic and more intuitive attempts, I realize this is beyond me.  I was hoping one of you JavaScript gurus out there could help me out with a simple script to add to each calculation field to make this work.

try67

Correct Answerby try67 on Dec 11, 2015 1:45 AM

I'll give you an example for the first field. You can use it to figure out the rest.

  1. var s = this.getField("Week01").valueAsString; 
  2. if (s=="") event.value = ""
  3. else
  4.     var d = util.scand("mm/dd/yyyy", s); 
  5.     d.setDate(d.getDate()+7); 
  6.     event.value = util.printd("mm/dd/yyyy", d); 

You should use this code as the custom calculation script of Week02.

This topic has been closed for replies.

2 replies

Participant
December 21, 2022

This is perfect, needed a little bit of tweaking for my use case but saved the day. Thank you.

shelbyanderson
Participant
July 5, 2017

Any help on this?