Hi,
I am using Windows Vista and Acrobat Adobe Extended Version 9.
I am struggling with a script. I am sure it is something simple; however, I am struggling mightily with it. I am getting an error message, shown below, that I am unable to understand and resolve.
I am trying to calculate age when given a birthdate. I used "Search" to find a script here at Adobe forums.
Here's the script that I am using:
//
StoneG, "Third Time Lucky to get Age from DOB entry" #1, 24 Oct 2006 7:21 am// Jared Langdon
// J. Langdon Consulting
//
www.jlangdon.ca// DOB = Date of Birth
var strDOBYear = Birthdate.rawValue.substr(6,4);
var strDOBMonth = Birthdate.rawValue.substr(0,2);
var strDOBDay = Birthdate.rawValue.substr(3,2);
var oDOB = new Date(parseInt(strDOBYear,10), parseInt(strDOBMonth,10)-1, parseInt(strDOBDay,10) );
var oToday = new Date();
// determine whether the person's birthday has already occurred this year
var bBirthdayHasOccurred = false;
if (oDOB.getMonth() < oToday.getMonth()) bBirthdayHasOccurred = true; if ((oDOB.getMonth() == oToday.getMonth()) && (oDOB.getDate() <= oToday.getDate())) bBirthdayHasOccurred = true;
var nCurrentAge = 0;
if (bBirthdayHasOccurred)
nCurrentAge = oToday.getFullYear() - oDOB.getFullYear();
else
nCurrentAge = oToday.getFullYear() - oDOB.getFullYear() - 1;
this.rawValue = nCurrentAge;
==========
I changed the script slightly. I changed from:
var strDOBYear = DateOfBirth.rawValue.substr(6,4);
to
var strDOBYear = Birthdate.rawValue.substr(6,4);
My variable is "Birthdate".
And I changed boolBirthdayHasOccurred to bBirthdayHasOccurred.
Upon opening the file in Acrobat 9, my error messages is as follows:
Acrobat JavaScript Debugger Functions Version 9.0
Acrobat EScript Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
Acrobat SOAP 9.0
Birthdate.rawValue has no properties
8:XFA:form1[0]:#subform[0]:Age[0]:calculate
The line above repeats several times. And then...
boolBirthdayHasOccurred is not defined
19:XFA:form1[0]:#subform[0]:Age[0]:calculate
boolBirthdayHasOccurred is not defined
19:XFA:form1[0]:#subform[0]:Age[0]:calculate
Birthdate.rawValue has no properties
8:XFA:form1[0]:#subform[0]:Age[0]:calculate
Birthdate.rawValue has no properties
I have no idea why it mentions "boolBirthdayHasOccurred" because that text is not even present. The last two lines repeat more several times.
When I have delete this entire script, the problems disappears. I have tried finding "boolBirthdayHasOccurred" without success.
Can someone point me in the right direction to troubleshoot this problem?
Regards,
Kevin