Skip to main content
Kathy409
Participating Frequently
July 17, 2023
Answered

Another Auto Populate for dates Question

  • July 17, 2023
  • 1 reply
  • 379 views

I've had this answered in the past for a similar query. I tried to use a previous script from a different form but i can't seem to make the adjustments for a new, different form.

 

It's a simple form for dates. I have 14 fields (Date1-Date14). I want to enter the beginning date in Date1 and the rest of the dates auto populate for two weeks.  The script I have seems to duplicate Date1 into Date2 then Date3 is fine. (Enter Date1 as 7/16. Date2=7/16, Date3=7/18). What am I missing so Date2 shows as 7/17?

 

Here's the script I'm using in "run Custom Validation Script" in Date1:

var date = util.scand("m/d/yy", event.value);
for( var i=2; i<=14; i++){
if(event.value == ""){
this.getField("Date2").value = "";
this.getField("Date"+i).value = "";}
else {
date.setDate(date.getDate() +1);
this.getField("Date2").value = event.value;
this.getField("Date"+i).value = util.printd("m/d/yy", date);}}

 

I've made several changes but it either duplicates Date1 into Date2 or doesn't complate any of them at all.  I've tried searching the forum but nothing seems to pop up.

 

Thanks!

This topic has been closed for replies.
Correct answer Bernd Alheit

Remove following line:

this.getField("Date2").value = event.value;

 

1 reply

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
July 17, 2023

Remove following line:

this.getField("Date2").value = event.value;

 

Kathy409
Kathy409Author
Participating Frequently
July 17, 2023

Thanks! That works!