These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Inserting Auto or Random Numbering

Maggie
Registered: Mar 13 2008
Posts: 2
Answered

Hi,

Question. Using LiveCycle, how do you insert a numeric form field that will generate a random number?

Thanks.

My Product Information:
Acrobat Pro 8.1.2, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Use JavaScirpt's "Math.random()" method to get a random number between 0 and 1.

George Kaiser

goldie6175
Registered: Feb 26 2008
Posts: 38
What would be the code for Auto Numbering. This would be a wonderful thing!
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You need to use the "JavaScript" language option in LiveCycle Designger.

The basic code is:

MyFieldName.rawValue = Math.random() ; // get a random number between 0 and 1.

If you want to generate a whole number:

var UpperLimit = 100; // upper limit of numbers to generate
var RandomNumber = Math.random() * UpperLimit; // Random number 0 - UpperLimit
MyFieldName.rawValue = Math.ceil(RandomNumber); // random integer 1 - UpperLimit

You can place the code as needed.

George Kaiser