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
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Link is no longer valid.
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);}}
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);
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.
Copy link to clipboard
Copied
Thanks Try, but a little late on the debug 😉
Copy link to clipboard
Copied
LOL... Better late than never, I guess.