Adding increasing dates to fillable PDF

New Here ,
Apr 01, 2020 Apr 01, 2020

Copy link to clipboard

Copied

Currently trying to make a timesheet template for work with a fillable pdf. I am trying to make it so when I input a date in a certain field, other fields (consecutive days of the week) will increase by one day. I can do it in excel (what the form was originally) but can't figure out how to do it in Acrobat. Thanks in advance for any help.

 

Example:

User inputs: 01-01-20

Next day (field): 01-02-20

This continues down the list of weekdays

TOPICS
Edit and convert PDFs , PDF forms

Views

374

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 01, 2020 Apr 01, 2020

Copy link to clipboard

Copied

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
New Here ,
Jul 22, 2022 Jul 22, 2022

Copy link to clipboard

Copied

Link is no longer valid.

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 ,
Jul 22, 2022 Jul 22, 2022

Copy link to clipboard

Copied

Here is a sample I did for someone else, it's used in a date field as validation script where you pick date, it will populate 14 fields with consecutive days, fields are called Text1-Text14, you would need to adapt it to your requirements of course:

var date = util.scand("mm/dd/yyyy", event.value);
for( var i=1; i<=14; i++){
if(event.value == "")
this.getField("Text"+i).value = "";
else {
date.setDate(date.getDate() +1);
this.getField("Text"+i).value = util.printd("mm/dd/yyyy", date);}}

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 01, 2020 Apr 01, 2020

Copy link to clipboard

Copied

I would suggest putting a script into the validate field of the initial date entry. This script will set the dates on all the consecutive date fields.

You'll find several posts here that provide solutions to this exact issue. 

But here's the basics for incrementing the day

 

var dateVal = util.scand("dd-mm-yy",event.valueAsString);

dateVal.setDate(dateVal.getDate()+1);

this.getField("NextDay").value = util.printd("dd-mm-yy",dateVal);

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Jul 22, 2022 Jul 22, 2022

Copy link to clipboard

Copied

There's no such property as event.valueAsString, I think you meant event.value...

However, it might also be a good idea to check if it's not empty, as that would be interpreted as the current date when supplied to the scand method, which will produce incorrect results.

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 ,
Jul 22, 2022 Jul 22, 2022

Copy link to clipboard

Copied

Thanks Try, but a little late on the debug 😉

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Jul 23, 2022 Jul 23, 2022

Copy link to clipboard

Copied

LATEST

LOL... Better late than never, I guess.

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