Reputation: 1
I'm creating a .pdf form in Foxit which needs to be able to generate a random, unique number each time the form is used. I presume the use of a button with javascript embedded is my best option however have not been successful in creating this. Suggestions?
Upvotes: 0
Views: 231
Reputation: 1598
var randomNumberField = this.getField("foo");
Do you have a "foo" field to run this on and to later populate with a number?
if you do, it's as simple as:
var randomNumberField = this.getField("foo")
if (randomNumberField .value.length == 0) {
randomNumberField .value = util.printf("%06d", Math.floor((Math.random() * 100000000) + 1));
}
and setting the field to be ReadOnly. code taken from here
no need for a button or anything, it runs on document load (i think?).
example pdf file (that will expire in 30 days....): https://easyupload.io/ew86ge
Upvotes: 1