Skip to main content
monicac58505423
New Participant
January 27, 2016
Answered

Autofill year +4 based on another year field

  • January 27, 2016
  • 1 reply
  • 1035 views

Hi,

I tried to modify some other script I found, but I really don't understand it well enough to make it work.  I am using Adobe Acrobat XI Pro.

I am calculating the expiration date of an extended warranty.  All dates are entered with the MM DD and YYYY in separate fields, due to the Manufacturer's form.

First Date is manually entered, date of original purchase.

2nd date is already set up to autofill current date.

3rd date is where I need help.  I have the MM and the DD as duplicate fields from the first date, this is working fine.  I need the "Year_3" field to automatically add 4 years to the YYYY from from the first date's "Year" field. 

Any help is appreciated.

This topic has been closed for replies.
Correct answer try67

If the first field is called Year1, use this custom calculation code for the second field:

var year1 = this.getField("Year1").valueAsString;

if (year1=="") event.value = "";

else event.value = Number(year1)+4;

1 reply

try67
try67Correct answer
Community Expert
January 28, 2016

If the first field is called Year1, use this custom calculation code for the second field:

var year1 = this.getField("Year1").valueAsString;

if (year1=="") event.value = "";

else event.value = Number(year1)+4;

August 7, 2019

Is there something similar to this? Where field one is set up to manually enter a date and then a series of fields auto fill? Field one = 8/7/2019 and then field two auto fills 8/8/2019, field three auto fills 8/9/2019, and so forth. Then if someone came and changed field one to another date, all other fields will adjust?

August 7, 2019

I found this that seems to work:

var date=new Date(this.getField("today").value);

date.setDate(date.getDate()-1);

event.value=util.printd("mm/dd/yyyy", date);

Only this is when I remove the "original date" I entered, the other cells don't clear out. Is there a way to do that?