# Random Text

**URL:** <https://forum.kirupa.com/t/random-text/22029>\
**Category:** flash\
**Created:** [May 29, 2003, 11:58am UTC](https://forum.kirupa.com/t/random-text/22029 "2003-05-29T11:58:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LATO](https://avatars.discourse-cdn.com/v4/letter/l/f17d59/32.png) [@LATO](https://forum.kirupa.com/u/LATO)\
**Post date:** [May 29, 2003, 11:58am UTC](https://forum.kirupa.com/t/random-text/22029/1 "2003-05-29T11:58:16Z")

</div>

Hi,

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:

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

```

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2003, 12:19pm UTC](https://forum.kirupa.com/t/random-text/22029/2 "2003-05-29T12:19:42Z")

</div>

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

```

??

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2003, 12:31pm UTC](https://forum.kirupa.com/t/random-text/22029/3 "2003-05-29T12:31:49Z")

</div>

that’s it! thanx

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2003, 12:32pm UTC](https://forum.kirupa.com/t/random-text/22029/4 "2003-05-29T12:32:28Z")

</div>

you’re welcome. 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2003, 12:36pm UTC](https://forum.kirupa.com/t/random-text/22029/5 "2003-05-29T12:36:15Z")

</div>

Hi,  
Or you could do it this way  
[AS]  
namesArr = new Array();  
namesArr = [“Fred”,“Kato”,“Mike”,“John”,“Kax”,“Cyrus”,“Susan”,“Jane”,“Amanda”,“Helen”,“Denise”];  
for(i=1;i\<namesArr.length;i++){  
inputTextField.text = namesArr[Number(random(i))];  
}[/AS]

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

SteveD
