How to auto-populate fields based on entry in another field...

Community Beginner ,
Apr 17, 2022 Apr 17, 2022

Copy link to clipboard

Copied

Hi!

 

I have a field for "Week Ending Date" and then I have individual fields for each date of that week.

 

I'd like those individual date fields to auto-populate the correct date when the "Week Ending Date" field is filled in.

 

Is that possible?

 

Thank you so much!

TOPICS
How to , PDF forms

Views

101

Likes

Translate

Translate

Report

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

correct answers 1 Correct answer

Adobe Community Professional , Apr 17, 2022 Apr 17, 2022

Yes, this is possible using a script.

Here's the basic code to do it (to be used as the calculation script for the field that needs to show the day before that date, for example):

 

var s = this.getField("WeekEndingDate").valueAsString;
if (s=="") event.value = "";
else {
	var d = util.scand("mm/dd/yyyy", s);
	d.setDate(d.getDate()-1);
	event.value = util.printd("mm/dd/yyyy", d);
}

Likes

Translate

Translate
Adobe Community Professional ,
Apr 17, 2022 Apr 17, 2022

Copy link to clipboard

Copied

Yes, this is possible using a script.

Here's the basic code to do it (to be used as the calculation script for the field that needs to show the day before that date, for example):

 

var s = this.getField("WeekEndingDate").valueAsString;
if (s=="") event.value = "";
else {
	var d = util.scand("mm/dd/yyyy", s);
	d.setDate(d.getDate()-1);
	event.value = util.printd("mm/dd/yyyy", d);
}

Likes

Translate

Translate

Report

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 ,
Apr 18, 2022 Apr 18, 2022

Copy link to clipboard

Copied

@try67 

Thank you!! You are amazing!! 🙂

 

By reading and following through your script I even managed to set it so that it displays only the date "dd" in the individual fields.

 

Thank you again so much!!

 

Have a great day!

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Apr 18, 2022 Apr 18, 2022

Copy link to clipboard

Copied

LATEST

Great, and you're very welcome!

Likes

Translate

Translate

Report

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