These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Display value that was input rather than calculated value

HankS
Registered: Apr 17 2009
Posts: 15
Answered

I need some help on this one. I have a date field that contains a custom calculation function. This function is used to increment the days of the week.

Here is the function:

function countDays(z){
var a = (1000*60*60*24) * z;
var b = 0;
var c = new Date();
var d = this.getField("date1").value;
if(d!=""){
var e = Date.parse(util.scand("mm/dd/yyyy", d));
c.setTime(e + a);
event.value = util.printd("mm/dd/yyyy",c);}
}

The function works fine for its purpose, however, there is an instance where the user can overrride this date and input their own date. This also works fine. The issue is that I want to display/retrieve the date that was input. When I attempt to display the inputted date from the field (in another field), it just displays the current date rather than the date that was input. I need it to display the date that the user inputs.
 
I suspect I need some keystroke event to commit the inputted value but I am not quite sure how to do this. I have tried various scripts, but I am begining to wonder if the original code placed on the calculation script is overriding any code I have tried in the keystroke event.

My Product Information:
Acrobat Pro 9.1, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
It is pretty hard, when you function forces the field value.

How or under what conditions are you calling the function?

It looks like your function adds the 'z' number of days to the date entered in the 'date1' field.

I would also comment the function and write it to be independent of date format, any date field, and adjusting any field field. The comments might help others understand what you are trying to do with your code.


George Kaiser

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Accepted Answer
In the calculation script you can check to see which field triggered the calculation (using event.source, event.source.name) and only perform the calculation if it was the "date1" field. This will allow a user to enter a different value and the field won't calculate if some other field value changes.
HankS
Registered: Apr 17 2009
Posts: 15
Thanks for the assist guys.