0

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?

LVM
  • 1
  • `var randomNumberField = this.getField("foo");` Do you have a "foo" field to run this on and to later populate with a number? – Yarin_007 May 10 '22 at 17:30
  • Please provide enough code so others can better understand or reproduce the problem. – Community May 11 '22 at 00:17

1 Answers1

1

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

Yarin_007
  • 1,449
  • 1
  • 10
  • 17