Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Autofill year +4 based on another year field

New Here ,
Jan 27, 2016 Jan 27, 2016

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.

TOPICS
Acrobat SDK and JavaScript , Windows
934
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 28, 2016 Jan 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;

Translate
Community Expert ,
Jan 28, 2016 Jan 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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 07, 2019 Aug 07, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 07, 2019 Aug 07, 2019
LATEST

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines