Random Text


I am trying to make a code that includes a list of names (probably in an array I think) and displays one name in an input text field.
I’m still learning al of this so maby someone can change this code a little bit so it works:

NumName = random(2);
pArray = ["test", "test2"];
inputtextfield = pIndex+NumName

As you can see, I have no idea what I am doing…

pArray = ["LATO", "kax"];
num = Math.floor(Math.random()*pArray.length);
inputTextField.text = pArray[num];


that’s it! thanx

you’re welcome. :wink:

Or you could do it this way
namesArr = new Array();
namesArr = [“Fred”,“Kato”,“Mike”,“John”,“Kax”,“Cyrus”,“Susan”,“Jane”,“Amanda”,“Helen”,“Denise”];
inputTextField.text = namesArr[Number(random(i))];

he above works well, but I think kax’s inclusion of Math.random may make it more efficient.