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

Form fields value change after saving & reopen

giac
Registered: Jan 18 2011
Posts: 5
Answered

I have problem with this time calculation script:
 
var vTime1 = TimeOut1.rawValue;
var vTime2 = TimeIn1.rawValue;
if (vTime1.length == 4 && vTime2.length == 4) {
var vTime1Minutes = parseInt(vTime1.substring(0, 1))*600 + parseInt(vTime1.substring(1, 2))*60 + parseInt(vTime1.substring(2, 4));
var vTime2Minutes = parseInt(vTime2.substring(0, 1))*600 + parseInt(vTime2.substring(1, 2))*60 + parseInt(vTime2.substring(2, 4));
if (vTime1Minutes > vTime2Minutes)
vTime1 = vTime2Minutes+1440 - vTime1Minutes;
else
vTime1 = vTime2Minutes - vTime1Minutes;
}
var Hours = Math.floor(vTime1/60);
var Minutes = vTime1%60;
if (Minutes < 10)
Minutes = "0" + Minutes;
this.rawValue = Hours + ":" + Minutes;
 
the purpose is to calculate the time between hours, it works fine once the fields are inserted but once saved and reopen the calcultion is weird.
For a similar script i get a NaN;Nan result, probably the error on the one above can solve even the second...
 
Can someone help?
Thanks in advance for your time!

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Are you sure the issue is with that calculation and not a calculation elsewhere in the form that relies on the results of that calculation?

When the form is reset, what is the result of that calculation?

Is the result of that calculation used elsewhere?

Do you allow for no entires in TimeOut1 and TimeIn1 and other user entered fields?

George Kaiser

giac
Registered: Jan 18 2011
Posts: 5
Tnx George for the prompt answer.

Let say the normal result is 3:20 (HH:MM) from a time in/out of 10:00 to 13:20, the result of the calculation after reset is 00:10. If I re-enter the timing the calculation return normal.
I insulated this calculation on a new form and still I get the error as above on reset, so it apparently is not a matter of result being used somewhere else, even if it is not used anywhere else and the variables has unique names.

Timings are user entered optional. The event is caluclate.
The timings are Time/Date fields HH:MM/Time, the result is text field but no difference if I put Date/Time with HH:MM.

giac
giac
Registered: Jan 18 2011
Posts: 5
Anyone can please help?

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Because of how forms fields can interact with one another, a sample form might be helpful.

George Kaiser

giac
Registered: Jan 18 2011
Posts: 5
here is the very simple form, fill in, save and reopen
thanks for your patience
www.tantimat.com/time_calc_test1.pdf
giac
Registered: Jan 18 2011
Posts: 5
Accepted Answer
I apparently find the solution reading almost the whole forum
and the answer was given by you George,

"If you change the field to a format of "None" you will see how Acrobat is handling this issue."

I changed the Binding to None and it worked fine, now when I save and reopen the calculation is perfect

If you can explain maybe will be helpful...

Thanks again!

giac
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
The 'Global' binding instructs LiveCycle Designer to treat field with the same name like the same field. So any value change to any of the fields so defined change the other fields with the same name.

George Kaiser