Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Another Auto Populate for dates Question

Community Beginner ,
Jul 17, 2023 Jul 17, 2023

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!

TOPICS
JavaScript , PDF , PDF forms
292
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jul 17, 2023 Jul 17, 2023

Remove following line:

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

 

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2023 Jul 17, 2023

Remove following line:

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

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 17, 2023 Jul 17, 2023
LATEST

Thanks! That works!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines