Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I add a sequential number generator into a text field?

Explorer ,
Feb 28, 2020 Feb 28, 2020

hi, please, i need the following, i actually have already seen the same request as mine and its answer somewhere on Adobe Support Community, but that channel is now closed, the answer, it provided is not clear on how i can add new JavaScript on Document JavaScript, given that the add button is not active on the "Document JavaScripts". 

 

Here is the question:

I need to add a tracking number to a PDF form. I would like the numbers for each form to be sequential. As an example, I would like to open my form (for the first time) and have the tracking number field show 0001. After I completely fill out the form and save it as a new document, I want that new document to have the number 0001 in the tracking number field, and the next time I open the "master form" I would like the tracking number field to show 0002. Is this possible? If so, how do I do this?

 

This response i saw on it, by "Gilad D (try67)":

You can embed this code in the document (via Tools - JavaScript - Document JavaScripts) to achieve that:

 

var f = this.getField("Tracking Number");
if (f.value=="") f.value = "0001";
else f.value = util.printf("%04d", (Number(f.value)+1));

Document JavaScripts.PNG

 

Please i will appreciate any support on this, thank you.

5.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
2 ACCEPTED SOLUTIONS
Community Expert ,
Feb 28, 2020 Feb 28, 2020

Enter a script name.

Press Add...

Delete the function definition.

Add your script.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2020 Feb 28, 2020

You can use any unused name, e.g. init

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2020 Feb 28, 2020

Enter a script name.

Press Add...

Delete the function definition.

Add your script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2020 Feb 28, 2020

Ok, thank you very much, can i add anything as a script name? or am i supposed to add a particular script name?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2020 Feb 28, 2020

Hi Bernd, Please is there a particular name i need to input as a script name to be able to add the script?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2020 Feb 28, 2020

You can use any unused name, e.g. init

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2020 Feb 28, 2020
LATEST

Ok, Bernd, thank you very much, it worked perfectly.

 

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