Highlighted

Auto Populating Text Fields

Community Beginner ,
Sep 30, 2020

Copy link to clipboard

Copied

Is there a way to auto populate a text field with consecutive numbers? Looking at the picture, say I start typing in 'Operation TypeRow1', I want the 'Op #' in that same row to auto populate as the number "10". and then when I start typing in Operation TypeRow2, I want the 'Op #' to auto populate to 20.

 

Side Question:

The Op # for a Rework is always 900. Say I type "Rework" into the 'Operation TypeRow', I want the cooresponding 'Op #' to auto populate as "900" but also keep the formatting mentioned above. Is this possible?

op number.PNG

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You can use something like this as the custom calculation script of the first "Op #" field:

 

var opType = this.getField("Operation TypeRow1").valueAsString;

if (opType=="") event.value = "";

else if (opType=="Rework") event.value = "900";

else event.value = "10";

 

Adjust the values and field names and you could use the same code for the other fields, too.

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

65

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

Auto Populating Text Fields

Community Beginner ,
Sep 30, 2020

Copy link to clipboard

Copied

Is there a way to auto populate a text field with consecutive numbers? Looking at the picture, say I start typing in 'Operation TypeRow1', I want the 'Op #' in that same row to auto populate as the number "10". and then when I start typing in Operation TypeRow2, I want the 'Op #' to auto populate to 20.

 

Side Question:

The Op # for a Rework is always 900. Say I type "Rework" into the 'Operation TypeRow', I want the cooresponding 'Op #' to auto populate as "900" but also keep the formatting mentioned above. Is this possible?

op number.PNG

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You can use something like this as the custom calculation script of the first "Op #" field:

 

var opType = this.getField("Operation TypeRow1").valueAsString;

if (opType=="") event.value = "";

else if (opType=="Rework") event.value = "900";

else event.value = "10";

 

Adjust the values and field names and you could use the same code for the other fields, too.

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

66

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
Sep 30, 2020 0
Most Valuable Participant ,
Sep 30, 2020

Copy link to clipboard

Copied

You can use something like this as the custom calculation script of the first "Op #" field:

 

var opType = this.getField("Operation TypeRow1").valueAsString;

if (opType=="") event.value = "";

else if (opType=="Rework") event.value = "900";

else event.value = "10";

 

Adjust the values and field names and you could use the same code for the other fields, too.

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...
Sep 30, 2020 1
Community Beginner ,
Oct 01, 2020

Copy link to clipboard

Copied

This worked great! Thank you!

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...
Oct 01, 2020 0