Dates in JavaScript

SethWilliams

In Runtime
Messages
125
I'm working on a time sheet in Acrobat Pro, and I want to auto calculate date fields based on one field's input. What I would like to do is have our users input the first monday on the timesheet, and then the rest of the week and the next week auto calculate. I have tried several ways using Javascript so far, but have had no luck getting it to calculate. I can display the value from one field, but when I try to add a day to it, the value disappears. Any ideas?
 

SethWilliams

In Runtime
Messages
125
Nobody?? Here is what I have so far:

var numDaysToAdd = 1; var inputDateString = getElementById("Date.1").value; var resultDate = stringToDate(inputDateString); resultDate.setDate( resultDate.getDate()+numDaysToAdd ); var result = dateToString( resultDate ); event.value = result;

I can get it to return a value if I put an actual date string in instead of getElementById("Date.1").value. Date.1 is the field that I want to pull user input date from.
 

SethWilliams

In Runtime
Messages
125
Just in case anyone was/is wondering, I was using JavaScript that is based for the web and not Adobe. Whoops! Anyway, here is the correct code that I used:

var numDaysToAdd = 1 ; var fromDate = util.scand("mm/dd/yyyy", this.getField("Date.1").value) ; var toDate = fromDate ; toDate.setDate(fromDate.getDate() + numDaysToAdd) ; event.value = util.printd("mm/dd/yyyy", toDate) ;
 
Top