Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).


New Forum | Previous | Next | (P-PDF) Beginners


Topic: adding dates in forms (Via Email), 1 Attachments
Conf: (P-PDF) Beginners, Msg: 139624
From: gkaiseril
Date: 9/18/2005 02:04 AM

For AcroForms not Designer.
You have to:
1. convert the inputted date string into a JavaScript date object
2. convert the date object to a numeric value, the number of milliseconds since the epoch date of January 1, 1970
3. for each date:
3.a. add the number of milliseconds in one day for each day from the inputted date
3.b. convert the resulting number back into the JavaScirpt date object
3.c. format the JavaScript object into formatted string.

See Adobe's JavaScript Scripting Reference, Adobe's JavaScript Scripting Guide, and Netscape"s JavaScript Core Reference 1.5 for more information about hierarchical fields, the JavaScript date object and properties.

// ---> start code
// get inputted date field value
var sDate = event.value;
// convert to date object - milliseconds since epoch date
oDate = util.scand("mm/dd/yyyy", sDate);
// convert date object into numeric value
nDate = oDate.valueOf();

/*
compute milliseconds in 1 day
24 hrs * 60 min * 60 sec * 1000 milliseconds
*/
var nMsec = 24 * 60 * 60 * 1000;

// get date parent name
sDateField = this.getField("Date");
// make into an array
aDateField = sDateField.getArray();
// next as date value
var nNext = nDate;
// next as date object
var oNext;

// loop through other days
for (i=1; i < aDateField.length; i++) {
// add i days of milliseconds to starting date
nNext = nDate + i * nMsec;
// convert to date object
oNext = new Date(nNext)
// format next date object
this.getField("Date." +i ).value = util.printd("mm/dd/yyyy", oNext);
}

// populate day of week
// array for day of week
var aDays = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

// loop through all days
for (i=0; i < aDateField.length; i++) {
// get date i
sDate = this.getField("Date." + i).value;
// convert to date object - milliseconds since epoch date
oDate = util.scand("mm/dd/yyyy", sDate);
// populate i day field
this.getField("Day." + i).value = aDays[oDate.getDay()];
}
// ---> end code

Click to open!7Days.pdf
Populate 7 Dates and Days Values (23,805 bytes)


PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Back to the past, 15 years ago! Open Publish 2002

Looking back to 2002, it's amazing how much of the prediction became a reality. Take a read and see what you think!

September 14, 2017
Platinum Sponsor





Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.

Features

Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.