I want to calculate a date that is exactly 5 days prior to a date chosen in a separate date field in a PDF Form. For example, if I choose "July 10, 2021" in Date1
, I want Date2
to automatically populate with "July 5, 2021".
I know how to grab the date from field 1 and populate field 2 with it, and I sort of know how to do a 5 day (ago) calculation. The part I'm really struggling with is putting those two things together in the document. If I wanted to calculate 5 days ago from the current date, I can do that no problem as it's documented all over planet earth and the internet lol. But calculating 5 days ago from a selected date in another field is throwing me for a loop.
I'm not well versed in JavaScript, but I'm also wondering if this might be a solution:
//turning this piece of code
event.value=this.getField("Date1").value;
//into this piece of code
var d = this.getField("Date1").value;
Since I don't need the second date field to actually populate with the first date field value, I'm wondering if it's as simple as turning the first field value into a variable and then dropping the variable into the calculation script under "Custom calculation script" in the form field's properties.
question from:
https://stackoverflow.com/questions/65846602/calculating-date-based-on-independent-form-field-in-pdf-form 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…