How to create a sequential numeric ID generator upgradable?

Hello good afternoon to members of the forum.

I have a doubt and I wonder how can I insert a script and javascript that I would generate a 4-digit sequential number in a text field, the numerical sequence should be updated every refresh I give the new form with the button I added to it, numerical sequence from 0001 to 1000
I thank the help and thank you, anyone who can send me send me email through the contact hurien1@hotmail.com


alex jose


3 Answers

Voted Best Answer

As long as you are working with that single copy of the form, you can keep a sequence number in it. And as you state that you do manually increment the sequence number, there are no issues with surprising updates.

You can follow Eugene's suggestion, but you will add the code to increment to the MouseUp event of your button (instead of the pageOpen event).

If your sequence number has to span multiple work sessions with the form, you'd have to make sure that the form file is always updated. Saving using JavaScript is a little bit of a mess, for "security reasons", so, the easiest might be to pop up a reminder to save. Otherwise, if you want to save the form "silently", you would have to set up a so-called trusted function which does the saving.

One more thing to be aware of is that the sequence number must not be reset when you reset the form. This is, however, easy to overcome… you would not only set the value of the field, but also its defaultValue when you increment it That would look like this:

this.getField("mySequenceID").value ++ ;
this.getField("mySequenceID*).defaultValue = this.getField("mySequenceID").value ;

That should now handle it.

Hope this can help.

Max Wyss.


By Max Wyss   

To Use this Script, add a Text Field to the PDF and name it "SeqFormID". If desired, place a seed value in the field. This example uses a pure number, so place any number in the field. Make this field ReadOnly and position it in a convenient location (top or bottom of page). Then duplicate the field to all pages where the Form ID will be displayed. It's a good idea to make sure the field looks good (font size, color, border, etc.) and is large enough before duplicating it.
Modify this script by changing format and the method for incrementing the Form ID. This technique can be generalized for use with distributed forms by acquiring the ID from an internet source or by using a random number technique to generate the number. Place this code in the Page Open event.

Code: // Get and increment Form ID
this.getField("SeqFormID").value++;


Eugene Williams   

Okay...I used the answers above to get my form to sequentially number. The numbering worked great! The problem I'm having now is that I have a master file of our invoice that several people will access each day. When I mouse over the number and it changes, I am saving the file as theInvoice Number and that's working well, too. But the problem is with the master file. It doesnt' retain the last number used, so that is a problem. Max Wyss (answer above) furnished a code in his answer to help with this, but I couldn't get it to work. I'm not very experienced with this, so I probably did something wrong. I really need this to work, so if anyone can help me, I would greatly appreciate it. What I need is for the form to sequentially number, be saved and the master form to retain the last number so when the next person opens the master file, the last number is there and it updates to the next number. One more thing, I was advised to make the field a read only field, but when you save the master file, then go back in, the number won't change unless you take the read only off.

Thanks in advance for your help. This s a great resource for someone like me.


Glenda Miley   


Please specify a reason: