Skip to main content
Inspiring
Nov 22, 2017 10:43 AM UTC
Answered

javascript on page open item

Hi (Acrobat CC)
I've become stuck on an issue. Please excuse me, I'm a designer not programmer, and have struggled to find a solution.

I have created a form which contains an 'on page open' javascript to fill a field with the following:

var today = new Date();

this.getField("Today").value = "GCF-01-" + util.printd("mmddyyyy", today);

this.getField("Today").readonly = true;

this performs the task I require, but I want this field 'locked' when populated, so that when the form is opened again the original date remains rather than being updated.

Would someone be able to help please?

MTIA Steve

This topic is closed to new replies. Start a new post to keep the conversation going.
Bernd Alheit
Bernd AlheitCorrect answer
Community Expert
Nov 22, 2017 12:36 PM UTC

Replace this line:

this.getField("Today").value = "GCF-01-" + util.printd("mmddyyyy", today);

4 replies

Bernd Alheit
Community Expert
Community Expert
Nov 22, 2017 11:58 AM UTC

Fill the field when it is empty:

if (this.getField("Today").value == "") this.getField("Today").value = "GCF-01-" + util.printd("mmddyyyy", today);

Translate
Inspiring
Nov 22, 2017 12:22 PM UTC

Hi Bernd

Many thanks, do I add your code after the existing?

I tried yours alone and nothing appeared.

Steve

Translate
Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
Nov 22, 2017 12:36 PM UTC

Replace this line:

this.getField("Today").value = "GCF-01-" + util.printd("mmddyyyy", today);

Translate