javascript on page open item

Nov 22, 2017

Copy link to clipboard

Copied

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

Replace this line:

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

TOPICS
Acrobat SDK and JavaScript

Views

112

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

javascript on page open item

Nov 22, 2017

Copy link to clipboard

Copied

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

Replace this line:

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

TOPICS
Acrobat SDK and JavaScript

Views

113

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 22, 2017 0
Nov 22, 2017

Copy link to clipboard

Copied

Fill the field when it is empty:

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 22, 2017 0
Nov 22, 2017

Copy link to clipboard

Copied

Hi Bernd

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

I tried yours alone and nothing appeared.

Steve

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 22, 2017 0
Nov 22, 2017

Copy link to clipboard

Copied

Replace this line:

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 22, 2017 0
Nov 22, 2017

Copy link to clipboard

Copied

thanks, that's my ignorance.

When I started to look at the two pieces of code I could see that might be the answer, thank you for confirming!

Steve

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 22, 2017 0