Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 11-12-2015, 10:39 AM   #1
In Runtime
 
Join Date: Mar 2013
Posts: 125
Default Dates in JavaScript

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 is offline   Reply With Quote
Old 11-23-2015, 03:50 PM   #2
In Runtime
 
Join Date: Mar 2013
Posts: 125
Default Re: Dates in JavaScript

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 is offline   Reply With Quote
Old 11-25-2015, 11:17 AM   #3
In Runtime
 
Join Date: Mar 2013
Posts: 125
Default Re: Dates in JavaScript

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) ;
SethWilliams is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 08:10 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0