Question: I have a form with a drop down menu, which has some categories (as `string`). When the user submits the form, I want to display a random text from the category that the user choose, but I have no idea how to do that.

I did it for one category, but I don't know how to do it for subsequent categories.

```
<script language="JavaScript">
<!--
var r_text = new Array ();
r_text[0] = "text1";
r_text[1] = "text2";
r_text[2] = "text3";

var i = Math.floor(3*Math.random())
document.write(r_text[i]);
//-->
</script>

```

Answer: 
something like this ?

```js
function select(){
  var categories = document.getElementById("mySelect").value;
  if(categories == "Funny"){
    var r_text = new Array ();
    r_text[0] = "funny_text1";
    r_text[1] = "funny_text2";
    r_text[2] = "funny_text3";

    var i = Math.floor(3*Math.random())
     document.getElementById("res").innerHTML = r_text[i];
  }else if (categories == "Serious"){
    var r_text = new Array ();
    r_text[0] = "Serious_text1";
    r_text[1] = "Serious_text2";
    r_text[2] = "Serious_text3";

    var i = Math.floor(3*Math.random())
     document.getElementById("res").innerHTML = r_text[i];
  }
}
```

```html
<select onchange="select()" name="" id="mySelect">
  <option>-----</option>
  <option value="Funny">Funny</option>
  <option value="Serious">Serious</option>
</select>

<div id="res"></div>
```
Well if you want a basic, non-database way to do this you could do something like the following:

```js
  var funny = ["AHAHAH.", "This is funny.", "Ok, don't judge."];

  var other = ["Quote 1", "Quote 2", "Quote 3"];

var category = funny;

var quote = category[[Math.floor(Math.random() * category.length)]];

document.getElementById("output").innerHTML = quote;
```

```html
<div id="output"></div>
```

Where the variable `quote` would be what you display and the variable `category` would be what the user picked.