Copy link to clipboard
Copied
I am completely new to Javascript and Acrobat both. I have a trial copy of Acrobat 9 that I'm working with.
I want to have a button (call it "GetThing") that when pressed will populate a text field (call it "RandomThing") from an array of items. I came across this code but am unsure of where to insert it (in the button? in the text field? both?) and unsure of exact syntax.
var myArray = ['January', 'February', 'March'];
var randThing = myArray[Math.floor(Math.random() * myArray.length)];
That seems like it will define the array and get a random value from it, but how can I get the variable randThing to actually show up in the text field when the button is pressed?
Thank you!
Copy link to clipboard
Copied
At the end of the code add this line and then place it as the button's MouseUp script:
this.getField("RandomThing").value = randThing;
Copy link to clipboard
Copied
At the end of the code add this line and then place it as the button's MouseUp script:
this.getField("RandomThing").value = randThing;
Copy link to clipboard
Copied
You, my friend, are amazing! Thank you!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more