Skip to main content
Known Participant
August 30, 2016
Answered

Calculation Field Not Updating- Javascript Issue

  • August 30, 2016
  • 3 replies
  • 3094 views

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";}

})();

This topic has been closed for replies.
Correct answer George_Johnson

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

3 replies

Known Participant
August 30, 2016

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)? 

George_JohnsonCorrect answer
Inspiring
August 31, 2016

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

Known Participant
August 31, 2016

Field Calculation Order did the trick and it is working great now.  THANK YOU!!!! 

Inspiring
August 30, 2016

Also, check to make sure that the field calculation order is correct.

Inspiring
August 30, 2016

Have you checked the JavaScript console (Ctrl+J) for any errors.

That one line should be:

var days = +getField("AddedDays").value;