Incremental dates in fields based on a manual date input in a "StartDate" field

New Here ,
Apr 02, 2019 Apr 02, 2019

Copy link to clipboard

Copied

I have this form with a start date that need to be manually input by the users. Based on that date, the fields 1 to 4 should be filled automagically with the "StartDate"+0,  "StartDate"+1, "StartDate"+2, "StartDate"+3, (...). How do I solve that with a Java script in Acrobat?

I'm thankfull for any help here!

/Getve

TOPICS
Acrobat SDK and JavaScript, Windows

Views

381

Likes

translate

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

Most Valuable Participant , Apr 02, 2019 Apr 02, 2019
Use this code as the custom calculation script of your fields:var startDateString = this.getField("StartDate").valueAsString;if (startDateString=="") event.value = "";else {    var startDate = util.scand("dd.mm.yy", startDateString);    startDate.setDate(startDate.getDate()+0); // change 0 to 1, 2, 3, etc. for the other fields    event.value = util.printd("dd.mm.yy", startDateString)}If you're interested, I've also developed a (paid-for) tool that allows you to set up such calculations very easi...

Likes

translate

Translate

Translate
Most Valuable Participant ,
Apr 02, 2019 Apr 02, 2019

Copy link to clipboard

Copied

Use this code as the custom calculation script of your fields:

var startDateString = this.getField("StartDate").valueAsString;

if (startDateString=="") event.value = "";

else {

    var startDate = util.scand("dd.mm.yy", startDateString);

    startDate.setDate(startDate.getDate()+0); // change 0 to 1, 2, 3, etc. for the other fields

    event.value = util.printd("dd.mm.yy", startDateString)

}

If you're interested, I've also developed a (paid-for) tool that allows you to set up such calculations very easily: Custom-made Adobe Scripts: Acrobat -- Apply Automatic Date Calculation

Likes

translate

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
New Here ,
Apr 03, 2019 Apr 03, 2019

Copy link to clipboard

Copied

Hi try67 & thanks!

Your code solved my challenge after a small adjustment. I changed startDate to startDateString in line 04 and 05 (as below) and voila; it worked!

var startDateString = this.getField("StartDate").valueAsString;

if (startDateString=="") event.value = "";

else {

    var startDateString = util.scand("dd.mm.yy", startDateString);

    startDateString.setDate(startDate.getDate()+0); // change 0 to 1, 2, 3, etc. for the other fields

    event.value = util.printd("dd.mm.yy", startDateString)

}

I'll certainly check out your tool if this scrifpting thing is getting a habbit... Again, thank you very much - brilliant!

Likes

translate

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