Fields that auto calculate date based on user input date.

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

104

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

Fields that auto calculate date based on user input date.

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

105

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
Jun 07, 2018 0
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
Reply
Loading...
Jun 07, 2018 1
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
Reply
Loading...
Jun 07, 2018 0
try67 LATEST
Jun 07, 2018

Copy link to clipboard

Copied

🙂 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
Reply
Loading...
Jun 07, 2018 0