Copy link to clipboard
Copied
I want to create a fillable form as a sign up list of players. After gathering X number of players, I would like to randomize as follows:
Sign ups:
Player 1 - Ann
Player 2 - Bob
Player 3 - Carl
(then, I assume, a button to iniiate randomizing the above with the results below:)
Randomize List:
Player 1 - Carl
Player 2 - Ann
Player 3 - Bob
Hopefully, the above example explains my desire. Is this possible? I can do it in Excel, but would like a fillable form application to to it. Suggestions?
Thank you in advance.
Try this code:
var maxFields = 4;
var values = [];
for (var i=1; i<=maxFields; i++) {
var v = this.getField("Text"+i).valueAsString;
if (v!="") values.push(v);
}
var newValues = [];
var usedIndexes = [];
while (newValues.length<values.length) {
var randomIdx = Math.floor(Math.random()*values.length);
while (usedIndexes.indexOf(randomIdx)!=-1)
randomIdx = Math.floor(Math.random()*values.length);
newValues.push(values[randomIdx]);
usedIndexes.push(randomIdx);
}
for (var i=1; i<=maxFie
...
Copy link to clipboard
Copied
How do you enter names?
You want to show random names in list box?
Copy link to clipboard
Copied
Sign ups via a fillable list of text boxes #1 through #4 for a team doubles tournament.
By randomizing players, the partner selection will also become randomized, thus insuring the competitions
aren't stacked in favor os those working the system. Hope that makes sense.
The below schedule is set and won't change. I want to alleviate players choosing which slot they may fill.
Round 1
#1 & #2 -v- #3 & #4
Round 2
#1 & #3 -v- #2 & #4
Round 3
#1 & #4 -v- #2 & #3
For this example, what I envision is four text bozex for the player snames to be entered. A button that will initiate a scripot to randomize, then the results to be displayed as above with player names instean of numbers.
Copy link to clipboard
Copied
I apologize for the "fat finger" spelling mistakes above. I have little experience with Javascript and really don't know if this is even possible. Just asking.
Copy link to clipboard
Copied
Try this code:
var maxFields = 4;
var values = [];
for (var i=1; i<=maxFields; i++) {
var v = this.getField("Text"+i).valueAsString;
if (v!="") values.push(v);
}
var newValues = [];
var usedIndexes = [];
while (newValues.length<values.length) {
var randomIdx = Math.floor(Math.random()*values.length);
while (usedIndexes.indexOf(randomIdx)!=-1)
randomIdx = Math.floor(Math.random()*values.length);
newValues.push(values[randomIdx]);
usedIndexes.push(randomIdx);
}
for (var i=1; i<=maxFields; i++) {
if (i<=newValues.length) this.getField("Text"+i).value = newValues[i-1];
else this.getField("Text"+i).value = "";
}
Copy link to clipboard
Copied
Where does this code go though..?
Copy link to clipboard
Copied
You can use it in a button as 'Mouse UP' action.