views:

32

answers:

1

Hello!

I have created a form in Adobe Pro and i have added some JavaScript to it. But i have two problems.

1) Is there a "Document Finished Loading"-action? I have a date field on the form and i would like that it automatically adds todays date into that field when the user opens the document to fill in the form fields.

2) The date method that i am using doesn't work properly, i have this code:

var dt = new Date();
var day = dt.getDate();
var month = dt.getMonth();
var year = dt.getFullYear();
var dagensdatum = year + "-" + month + "-" + day;
var datum = this.getField("Datum");
datum.value = dagensdatum;
datum = this.getField("Datum2");
datum.value = dagensdatum;
datum = this.getField("Datum3");
datum.value = dagensdatum;

But when i run this, it prints out 11th of April and not todays date. Any ideas?

+1  A: 

Hi,

for your 2nd question I don't know why the date is not correct, but at least, you should do this :

var month = dt.getMonth();
month++;

because the getMonth() returns an int between 0 and 11. As for the day, I don't know what could cause the problem.

Edit : Have you checked your own date on your computer? Because if it is wrong it will be displayed uncorrectly in your browser. I guess you should have a date of 11th May in your computer, don't you?

Michael Lumbroso
I found another way to get around the problem using Utils.
Patrick
Lol @ 1 month delay for a 2 hours answer..... Nice consideration for contributors.
Michael Lumbroso