These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Create a list box with dates

kukka
Registered: Jun 1 2011
Posts: 16

Hi
 
I would like to create a list box with 4 different dates for the user to choose.
 
Please help me out with the code. Thanks
 
current date + 3months
current date + 6 months
current date + 9 months
current date + 12months

kukka
Registered: Jun 1 2011
Posts: 16
Forgot to mention I am using acrobat forms 9.0 pro
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Have you carefully thought this through?

Each day the form is opened the options will change. This may cause a problem when the form is saved, unless you do some special setup and scripting.

The script for computing the dates:

// open the JS console
// get the current date ogject:
var oNow = new Date();
// get the month from the date object
var nNowMonth = oNow.getMonth();
// add 3 months
var o3Months = new Date(oNow.getFullYear(), (nNowMonth + 3), oNow.getDate(), 0, 0, 0, 0);
// format strting
var s3Months = util.printd("mmm d, yyyy", o3Months);
// add 6 months
var o6Months = new Date(oNow.getFullYear(), (nNowMonth + 6), oNow.getDate(), 0, 0, 0, 0);
// format strting
var s6Months = util.printd("mmm d, yyyy", o6Months);
// add 9 months
var o9Months = new Date(oNow.getFullYear(), (nNowMonth + 9), oNow.getDate(), 0, 0, 0, 0);
// format strting
var s9Months = util.printd("mmm d, yyyy", o9Months);

// results of the above scrpt
console.show();
// console.clear();
console.println("Today: " + util.printd("mmm dd, yyyy", oNow));
console.println("In 3 months: " + s3Months);
console.println("In 6 months: " + s6Months);
console.println("In 9 months: " + s9Months);


George Kaiser

kukka
Registered: Jun 1 2011
Posts: 16
thanks gkaiseril for your help.