Copy link to clipboard
Copied
I have an Adobe Acrobat DC form with what I believe is a simple issue but has me stumped. I have a field (InitialDate) in which the user inputs a date. I have another field in which the user inputs the number of days (AddedDays) . I want the third field FinalDate to calculate the value by adding the specified number of days from AddedDays to the InitialDate. Below is the javascript I have added to under the calculate in the FinalDate field.
The javascript works great except when the user CHANGES the date in the InitialDate field, the FinalDate field is not updating. If the user changes the AddedDays input, the FinalDate field is updating. Can someone help me?
(function () {
var sDate = getField("InitialDate").valueAsString;
var d = util.scand("m/d/yy", sDate);
var days = getField("AddedDays").value;
d.setDate(d.getDate() + days);
if (sDate) {event.value = util.printd("m/d/yy", d);}
else {event.value = "No Transmission Date Entered";}
})();
1 Correct answer
Yes, you need to correct the field calculation order as mentioned earlier. Exactly how you do this depends on which version of Acrobat you're using.
While you're in form editing mode, select:
Acrobat 9: Forms > Edit Fields > Set Field Calculation Order
Acrobat 10: Tasks > Other Tasks > Edit Fields > Set Field Calculation Order
Acrobat 11: Tasks > Other Tasks > Set Field Calculation Order
Acrobat DC: More (button in right-hand panel) > Set Field Calculation Order
Copy link to clipboard
Copied
Have you checked the JavaScript console (Ctrl+J) for any errors.
That one line should be:
var days = +getField("AddedDays").value;
Copy link to clipboard
Copied
Also, check to make sure that the field calculation order is correct.
Copy link to clipboard
Copied
So, I think I've found my issue which still has me confused. For the purpose of simplification, I didn't actually explain my full scenario. The "InitialDate" field is actually a calculated field itself from another field called "DateRequest". So, the formula is trying to use a field that is a calculated field in and of itself. Is there a way to order it so that all fields are immediately updated (like in a 'mouse up' event)?
Copy link to clipboard
Copied
Yes, you need to correct the field calculation order as mentioned earlier. Exactly how you do this depends on which version of Acrobat you're using.
While you're in form editing mode, select:
Acrobat 9: Forms > Edit Fields > Set Field Calculation Order
Acrobat 10: Tasks > Other Tasks > Edit Fields > Set Field Calculation Order
Acrobat 11: Tasks > Other Tasks > Set Field Calculation Order
Acrobat DC: More (button in right-hand panel) > Set Field Calculation Order
Copy link to clipboard
Copied
Field Calculation Order did the trick and it is working great now. THANK YOU!!!!

