Highlighted

Random Number Generator

Explorer ,
Jun 17, 2020

Copy link to clipboard

Copied

I am using a Java Script below to randomly generate a number used for a quote number:

 

this.getField("Quote #").value = (Math.floor(Math.random()*Math.pow(10,13)));

 

It does as it should, everytime you save or close the pdf it generates a new rnadom number.  Is there a way once a copy has been saved that it saves that random number that was generated?  I am trying to use this for generating a quote number to keep on file but once it is saved and reopened it generates a new number.

 

Thanks for your help!

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

Use this:

if (this.getField("Quote #").value == "")

this.getField("Quote #").value = (Math.floor(Math.random()*Math.pow(10,13)));

Topics

Acrobat SDK and JavaScript

Views

88

Likes

Translate

Translate

Report

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

Random Number Generator

Explorer ,
Jun 17, 2020

Copy link to clipboard

Copied

I am using a Java Script below to randomly generate a number used for a quote number:

 

this.getField("Quote #").value = (Math.floor(Math.random()*Math.pow(10,13)));

 

It does as it should, everytime you save or close the pdf it generates a new rnadom number.  Is there a way once a copy has been saved that it saves that random number that was generated?  I am trying to use this for generating a quote number to keep on file but once it is saved and reopened it generates a new number.

 

Thanks for your help!

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

Use this:

if (this.getField("Quote #").value == "")

this.getField("Quote #").value = (Math.floor(Math.random()*Math.pow(10,13)));

Topics

Acrobat SDK and JavaScript

Views

89

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Jun 17, 2020

Copy link to clipboard

Copied

Use this:

if (this.getField("Quote #").value == "")

this.getField("Quote #").value = (Math.floor(Math.random()*Math.pow(10,13)));

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Jun 17, 2020

Copy link to clipboard

Copied

Thats exactly what I was looking for!  Thanks!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Resources
One Stop Solution for Acrobat
Edit a PDF