Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Button that enters random number (between 1 and 21) in 100 diff fields

New Here ,
Feb 24, 2020 Feb 24, 2020

I can't work this one out.

See image... I have 100 fields that i need a script on a button to enter a random number from 1 to 20 in them. The red button already clears them.

Any advice?

 

Capture.JPGexpand image

 

 

TOPICS
PDF forms
424
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2020 Feb 25, 2020

What are those fields called?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 25, 2020 Feb 25, 2020

currently Tex01 to Tex100, but can be whatever is easiest

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2020 Feb 25, 2020

You can use this code:

 

for (var i=1; i<=100; i++) {
var n = Math.floor(Math.random()*21)+1;
if (n==22) n--;
if (i<10) this.getField("Tex0"+i).value = n;
else this.getField("Tex"+i).value = n;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 25, 2020 Feb 25, 2020
LATEST

You rock, ty!

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