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

Fields that auto calculate date based on user input date.

New Here ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

I have a form that requires 7 day history from date of application. The user inputs the application date. I then have 7 separate fields that should auto calculate the past 7 days from the user input. For example: user input = 06/07/2018

Prior 7Prior 6Prior 5Prior 4Prior 3Prior 2Prior 1
05/31/201806/01/201806/02/201806/03/201806/04/201806/05/201806/06/2018


With the dates in the table above being auto-calculated in 7 separate fields. Let me know if I'm not making any sense. Also, here's something that I found to try and adapt to what I need, but my coding knowledge is small and not in Java at all haha so any help is appreciated.

var dateString = this.getField("Date of Application").value; 

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

else { 

    var d = util.scand("mm/dd/yyyy", dateString); 

    d.setDate(d.getDate()-7); 

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

Thanks.

TOPICS
Acrobat SDK and JavaScript

Views

128

Likes

Translate

Translate

Report

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
Community Expert ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

The code you found is correct, for the last day in the series. What happens when you place it as the custom calculation script of that field?

Likes

Translate

Translate

Report

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
New Here ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

When I put it in the prior 7 field nothing happens. Am I supposed to do something special to trigger the script?

Edit: I was putting the script in the validation field. I put it in the calculation field and it worked haha. I feel dumb, but thank you for talking it out with me.

Likes

Translate

Translate

Report

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
Community Expert ,
Jun 07, 2018 Jun 07, 2018

Copy link to clipboard

Copied

LATEST

🙂 Not a problem!

Likes

Translate

Translate

Report

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