Groups > Software Support > Adobe Acrobat Scripting > Re: How do I add this script to change an experation date!




How do I add this script to change an experation date!

How do I add this script to change an experation date!
Mon, 12 May 2008 09:17:52 -070
Hello,

I have used a script on my website for some coupons that expire two days after
the date on the person that is veiwing them on there computer using the date on
their computer (makes people get ahold of me quicker because the coupon expires
quickly0.

I am kind of new to scripting I have gone into LIveCycle I have Acrobat 8
installed. What I want to do is put this script in place for a date where there
is text. Can anyone help me out with this I'd really appreciate it!! The script
is as follows.



Post Reply
Re: How do I add this script to change an experation date!
Mon, 12 May 2008 09:30:48 -070
Post Reply
Re: How do I add this script to change an experation date!
Mon, 12 May 2008 09:34:39 -070
One post is enough to get an answer.

Do you want the coupon expiration date to appear on the coupon?

Use the Date Time object within Acrobat JavaScript to populate this field.

Or

Do you want the PDF to no longer work?

Then you need to use the LiveCycle Server product to manage the digital rights.
Although there is a limited JavaScript cover that could be used but turning off
JavaScript in Acrobat/Reader renders this useless.

If you are going to use LiveCycle Designer, you have a choice of using FormCalc
or JavaScript. Each handles the date/time object a little differently. FormCalc
handles date calculations by the number of days and JavaScript uses
milliseconds.

Post Reply
Re: How do I add this script to change an experation date!
Mon, 12 May 2008 11:21:15 -070
I would like the experation date to appear on the coupon.
I do have a coupon page on my website where I have used java script to have the
date acouple of days ahead show up on the web page with the coupons on it.
Here is a link to the page so you can see what I am doing now and what I want to
do in Acrobat thru LiveCycle Designer

 <http://www.uptownimports.com/promotions.html>

Sorry about the multiple posts!!

This is the code below.

JavaScript Date Display

//Just Copy the javascript code code below and put it between the tags of //your
html page.


function dispDate(dateVal) {
DaystoAdd=dateVal
TodaysDate = new Date();
TodaysDay = new Array('Sunday', 'Monday', 'Tuesday','Wednesday', 'Thursday',
'Friday', 'Saturday');
TodaysMonth = new Array('January', 'February', 'March','April', 'May','June',
'July', 'August', 'September','October', 'November', 'December');
DaysinMonth = new Array('31', '28', '31', '30', '31', '30', '31', '31', '30',
'31', '30', '31');
function LeapYearTest (Year) {
if (((Year % 400)==0) || (((Year % 100)!=0) && (Year % 4)==0)) {
return true;
}
else {
return false;
}
}
CurrentYear = TodaysDate.getYear();
if (CurrentYear < 2000) CurrentYear = CurrentYear + 1900; currentMonth =
TodaysDate.getMonth(); DayOffset = TodaysDate.getDay(); currentDay =
TodaysDate.getDate(); month = TodaysMonth[currentMonth]; if (month ==
'February') { if (((CurrentYear % 4)==0) && ((CurrentYear % 100)!=0) ||
((CurrentYear % 400)==0)) { DaysinMonth[1] = 29; } else { DaysinMonth[1] = 28; }
} days = DaysinMonth[currentMonth]; currentDay += DaystoAdd; if (currentDay >
days) {
if (currentMonth == 11) {
currentMonth = 0;
month = TodaysMonth[currentMonth];
CurrentYear = CurrentYear + 1
}
else {
month =
TodaysMonth[currentMonth+1];
}
currentDay = currentDay - days;
}
DayOffset += DaystoAdd;
function offsettheDate (offsetCurrentDay) {
if (offsetCurrentDay > 6) {
offsetCurrentDay -= 6;
DayOffset = TodaysDay[offsetCurrentDay-1];
offsettheDate(offsetCurrentDay-1);
}
else {
DayOffset = TodaysDay[offsetCurrentDay];
return true;
}
}
offsettheDate(DayOffset);TheDate = DayOffset + ', ';
TheDate += month + ' ';
TheDate += currentDay + ', ';
if (CurrentYear<100) CurrentYear="19" + CurrentYear; TheDate +=
CurrentYear; document.write(' '+TheDate); }





//Then just call the function at the point you want the date to display, like
so:


dispDate(0)


//The number in the brackets is the number of days you want to add to the
current date.



Thanks in advance
Post Reply
Re: How do I add this script to change an experation date!
Mon, 12 May 2008 12:45:41 -070
For the LiveCycle Designer form:

Far to complex.

In FormCalc with a formatted date field of "MMM DD, YYYY" the
calculation script:

$.formattedValue = Num2Date(Date + 2, "MMM DD, YYYY")

For JavaScript:

var oExpire = new Date(new Date().valueOf() + (2 * 24 * 60 * 60 * 1000)); //
today's date plus 2 days in milliseconds
$.formattedValue = util.printd("MMM DD, YYYY", oExpire, true); //
formatted expiration date

or for HTML, Acrobat AcorForm, or LiveCycle Designer a funciton to advance
today's date by a passed number of days:

function ExpireDate(fNumDays) {
	var Now = new Date(); // get today's date time object
	var nFullYear = Now.getFullYear(); // get the full year from the object
	var nMonth = Now.getMonth(); // get the month from the object
	var nDate = Now.getDate(); // get the date from the object
	return new Date(nFullYear, nMonth, nDate + 2); // return date time object
advanced by fNumDays
Post Reply
<< Previous 1 2 3 Next >>
( Page 1 of 3 )
about | contact