Expand my Community achievements bar.

SOLVED

Autofill a date and stay at that date

Avatar

Level 4

Hi,

I have a form in which I'd like to have a date field auto fill when a check box is checked.  I've done where I can get today's date to appear, but then any time I open the form the date updates to the current date.  This is a form that is going through an approval process and so the timeline of dates needs to appear accurately.  Is there someway to do this?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi, 

Here is the form back.

The num2date() is a FormCalc function, so I have changed the language in the checkbox click event and changed the script syntax to suit.

https://acrobat.com/#d=J0xm9pTEHV7K5HIrFQXxow

Hope that helps,

Niall

View solution in original post

6 Replies

Avatar

Level 10

Hi,

It depends on what script you have and in what event you are using.

If you have the script in aany of the following: initialise, layout:ready or docReady, then it is likely that the date will update when the form is opened.

However if you put the script in the click event of the checkbox, then it will only update when the checkbox is clicked.

You way want to wrap it in an if statement, checking that the checkbox .rawValue == 1, eg it is ticked.

Lastly, make sure that there isn't any script in the date field.

Hope that helps,

Niall

Avatar

Level 4

Niall,

I get what you're saying, but there are other things that will be going on with the click script as well -- making a button appear.  Does the date portion need to be in FormCalc?  The other is in JavaScript.  I've included a sample of what I'm trying to do.  I'm not totally sure I have the script totally correct the date either.

https://acrobat.com/#d=XszzEmfKBzUke*mmwaAYUg

Thanks!

Avatar

Level 10

Hi,

It looks like you haven't done the last step and Published the document on Acrobat.com:

Acrobat.com.png

You need to do this, before I can access it.

In any one object, the script needs to be all FormCalc OR all JavaScript. You can't mix languages within an event. Different events in an object use different languages.

So if you script for the date is FormCalc, stick with that syntax for the rest of the script.

Niall

Niall

Avatar

Correct answer by
Level 10

Hi, 

Here is the form back.

The num2date() is a FormCalc function, so I have changed the language in the checkbox click event and changed the script syntax to suit.

https://acrobat.com/#d=J0xm9pTEHV7K5HIrFQXxow

Hope that helps,

Niall

Avatar

Level 4

Thanks that did help a lot.  Can you recommend a reference that would help me understand how to adjust JavaScript to FormCalc or vice versa?