Copy link to clipboard
Copied
I have an excel that lets me enter a date, and it autofills the highlighted areas with the date end rage of 2 weeks from the initial date entered. It autofills the dates next to the days. I am new to Acrobat, but need to redo our timesheet as a fillable PDF instead of using Excel. Please help!
Lets say your field names are "Date1-Date14", use this as validation script of "CalendarMain" field (field where you select start date):
var date = util.scand("mm/dd/yyyy", event.value);
for( var i=2; i<=14; i++){
if(event.value == ""){
this.getField("Date1").value = "";
this.getField("Date"+i).value = "";}
else {
date.setDate(date.getDate() +1);
this.getField("Date1").value = event.value;
this.getField("Date"+i).value = util.printd("mm/dd/yyyy", date);}}
Copy link to clipboard
Copied
Hi there
Hope you are doing well and sorry for the trouble.
The workflow you are trying to do is might be possible using the custom JavaScript. For more information about using the Javascript please check the help page - https://acrobatusers.com/tutorials/javascript_console/
Regards
Amal
Copy link to clipboard
Copied
You don't have fields where dates should go?
Do you want first date to be same as input date or it starts with +1 day?
Copy link to clipboard
Copied
Yes, the first day would be the date entered. Below is our current sheet. When you enter a date in the "FROM" cell, it will autofill the rest of the dates shown.
Copy link to clipboard
Copied
Lets say your field names are "Date1-Date14", use this as validation script of "CalendarMain" field (field where you select start date):
var date = util.scand("mm/dd/yyyy", event.value);
for( var i=2; i<=14; i++){
if(event.value == ""){
this.getField("Date1").value = "";
this.getField("Date"+i).value = "";}
else {
date.setDate(date.getDate() +1);
this.getField("Date1").value = event.value;
this.getField("Date"+i).value = util.printd("mm/dd/yyyy", date);}}
Copy link to clipboard
Copied
This worked! This has been extremely helpful! I have seen you post on other pages and i appreciate you taking the time, yet again, to assist a novice.
Copy link to clipboard
Copied
This works great! However, we enter the last day of the pay period instead of the first day. How would I change the script for that? Thanks!
Copy link to clipboard
Copied
Change:
date.setDate(date.getDate() +1);
To:
date.setDate(date.getDate() -1);