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

If statement using dates and ages

jrodcody1
Registered: Sep 23 2009
Posts: 2
Answered

I am trying to get an If/Else statement to return a calculated date. Since I don't know how to JavaScript, I have been looking in the adobe forums and other googled sources. I can't seem to get anything to work. Here's what the issue is.

The form I am working in imports data from another form using a saved FDF file. Among the fields that it imports are ones called AGE, DateStart (which is the person's birthdate), and DateEnd (which is the current date).

In this form, I have created fields called ExpDate and ExpDatePed. ExpDate calculates a date 10 years out from the DateEnd field (10 years from the current date). ExpDatePed calculates a date 18 years out from the DateStart field (the person's 18th birthday). All of these fields are working properly.

I have another text field called Text1. This is the one I am having trouble with. What I need this field to do is use an if/else statement to determine whether to return the value in the ExpDate field or the value in the ExpDatePed field by determining if the number in the AGE field is less than 18 or not.

Here's the script I was trying to use, but it says that there are illegal characters.

Any help would be greatly appreciated.

var strStart=this.getField(“ExpDate”).value;

var strEnd=this.getField(“ExpDatePed”).value;

var strYears=this.getField(“AGE”).value;

if(strYears<18)

{

event.value=strEnd;

}

else

{

event.value=strStart;

}

My Product Information:
Acrobat Pro 9.0, Windows
suewhitehead
Registered: Jun 3 2008
Posts: 232
Time and dates are rather complicated to calculate. Search for and study Thom Parker's tutorial on Acrobat Users on this topic if you want to use this type of calculation.
Hope this helps.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
First you have to figure out what is going into the fields. So I would change the fields in question to a format of "None" and see what string values are being imported.

George Kaiser