PDA

View Full Version : Adding buttons to a sentence generator.



tivaelydoc
12-30-2008, 02:34 AM
So I've got this generator:

http://tivaelydoc.110mb.com/test2.html

But in the full version, I have 6 vars and 13 different tests.

Is there a way to make a button or a html link to generate each one into a single text box?

I know that I would have to define each test (ex: test1, test2, etc.) but what I don't know how to do is have a text box so that every time you click on one of the test buttons, a new generated string of words generates according to which button you clicked.

Nile
12-30-2008, 02:39 AM
Do you have an example, I don't extremely get what you want. Do you want the buttons to be like: Ted, Bob, Bill, Stabbed, Hugged, Punch...?

tivaelydoc
12-30-2008, 02:56 AM
The generator in the demo generates this:

test = one[r(one.length)] + " " + two[r(two.length)] + " " + three[r(three.length)] + ".";

one being var one etc.

I've got 13 different versions of this and they generate all different sentences, such as two + three + six or whatever.

Normally, the only way you can regenerate the text is by refreshing.

So, what I want the buttons to be are all the different types of sentence generators.

Let's say the first button just generates this (from the demo):

test1 = one[r(one.length)] + ".";

and the second one generates this:

test2 = one[r(one.length)] + " " + two[r(two.length)] + " " + three[r(three.length)] + ".";

Instead of having to refresh to regenerate, I want to make buttons called whatever that when clicked generate the adjacent string into a dynamic text box.

I have a full example of what I'm talking about, but due to extreme explicit text, I don't think I can post it here. Although, if you're not easily offended, I can PM it to you.

Nile
12-30-2008, 03:17 AM
I've send you a PM.

Nile
12-30-2008, 04:10 AM
Here, this should work:


<script type="text/javascript">
var love = {
names: ["Bill","Tom","Caroline","Macey"],
actions: ["made cookies for","kissed","hugged","broke up with","got together with"],
};

var violence = {
names: ["Bill","Tom","Caroline","Macey"],
actions: ["stole from","punched","hit","stabbed"],
};

var social = {
names: ["Bill","Tom","Caroline","Macey"],
actions: ["chatted with","went out with","called","emailed"],
};
var randArr = function(arr){
arr = arr.length;
arr = Math.floor(Math.random()*arr);
return arr;
}
var setRandom = function(type,el){
var random;
random = type.names[randArr(type.names)] +" "+ type.actions[randArr(type.actions)] +" "+ type.names[randArr(type.names)];
el = document.getElementById(el).getElementsByTagName('input');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

</script>

<div id="inputHolder">
<input type="button" onClick="setRandom(love,'inputHolder');" value="Love" />
<input type="button" onClick="setRandom(violence,'inputHolder');" value="Violence" />
<input type="button" onClick="setRandom(social,'inputHolder');" value="Social" />
<br />
<br />
<input type="text" style="width:500px;height:50px;font-size:30px;font-family:arial;/>
</div>


I hope this works for you.

tivaelydoc
12-30-2008, 06:47 AM
Thanks, that worked exactly how I wanted it and then some!

Since input type="text" is single line, I changed it to:


<textarea id="text" name="text" style="width:100%;height:150px;font-size:2em;font-family:garamond;color:#990000;text-transform: uppercase;"></textarea>

so I can have multiple line.

Then I changed the setRandom to:


var setRandom5 = function(type,el){
var random;
random = type.subjects[randArr(type.subjects)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

But when I click on:


<input type="button" onClick="setRandom5(violence,'inputHolder');" value="Violence" />

nothing happens. How come?

Nile
12-30-2008, 06:50 AM
Post all of your code please.

tivaelydoc
12-30-2008, 06:54 AM
I haven't refined it, but I know it worked:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>


<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>Untitled Document</title>
<style type="text/css">
body {background-color: black}
</style>
</head>
<body spellcheck="false">
<p valign="middle"><center>
<script type="text/javascript">

var violence = {

adverbs: ["Bill","Tom","Caroline","Macey"],

adjectives: ["stole from","punched","hit","stabbed"],

subjects: ["chatted with","went out with","called","emailed"],

presentverbs: ["made cookies for","kissed","hugged","broke up with","got together with"],

pastverbs: ["stole from","punched","hit","stabbed"],

nouns: ["chatted with","went out with","called","emailed"],
};

var randArr = function(arr){
arr = arr.length;
arr = Math.floor(Math.random()*arr);
return arr;
}

var setRandom1 = function(type,el){
var random;
random = type.subjects[randArr(type.subjects)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

var setRandom2 = function(type,el){
var random;
random = type.nouns[randArr(type.nouns)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

var setRandom3 = function(type,el){
var random;
random = type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

var setRandom4 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

var setRandom5 = function(type,el){
var random;
random = type.subjects[randArr(type.subjects)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

var setRandom6 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

var setRandom7 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

var setRandom8 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

var setRandom9 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

var setRandom10 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

var setRandom11 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

var setRandom12 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

var setRandom13 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).getElementsByTagName('textarea');
for(i=0;i<el.length;++i){
if(el[i].type == "text"){
el[i].value = random
}
}
}

</script>

<div id="inputHolder">
<input type="button" onClick="setRandom1(violence,'inputHolder');" value="Love" />
<input type="button" onClick="setRandom2(violence,'inputHolder');" value="Violence" />
<input type="button" onClick="setRandom3(violence,'inputHolder');" value="Social" />
<input type="button" onClick="setRandom4(violence,'inputHolder');" value="Love" />
<input type="button" onClick="setRandom5(violence,'inputHolder');" value="Violence" />
<input type="button" onClick="setRandom6(violence,'inputHolder');" value="Social" />
<input type="button" onClick="setRandom7(violence,'inputHolder');" value="Love" />
<input type="button" onClick="setRandom8(violence,'inputHolder');" value="Violence" />
<input type="button" onClick="setRandom9(violence,'inputHolder');" value="Social" />
<input type="button" onClick="setRandom10(violence,'inputHolder');" value="Love" />
<input type="button" onClick="setRandom11(violence,'inputHolder');" value="Violence" />
<input type="button" onClick="setRandom12(violence,'inputHolder');" value="Social" />
<br />
<br />
<textarea id="text" name="text" style="background:black;width:100%;height:150px;font-size:2em;font-family:garamond;color:#990000;text-transform: uppercase;"></textarea>
</div>
</center></p>
</body></html>

Here's the working version:

http://tivaelydoc.110mb.com/java4.html

Nile
12-30-2008, 07:05 AM
It's something very messy now.
I can make it cleaner, if you don't want me to, he's your code:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>


<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>Untitled Document</title>
<style type="text/css">
body {background-color: black}
</style>
</head>
<body spellcheck="false">
<p valign="middle"><center>
<script type="text/javascript">

var violence = {

adverbs: ["Bill","Tom","Caroline","Macey"],

adjectives: ["stole from","punched","hit","stabbed"],

subjects: ["chatted with","went out with","called","emailed"],

presentverbs: ["made cookies for","kissed","hugged","broke up with","got together with"],

pastverbs: ["stole from","punched","hit","stabbed"],

nouns: ["chatted with","went out with","called","emailed"],
};

var randArr = function(arr){
arr = arr.length;
arr = Math.floor(Math.random()*arr);
return arr;
}

var setRandom1 = function(type,el){
var random;
random = type.subjects[randArr(type.subjects)];
el = document.getElementById(el).value = random;
}

var setRandom2 = function(type,el){
var random;
random = type.nouns[randArr(type.nouns)];
el = document.getElementById(el).value = random;
}

var setRandom3 = function(type,el){
var random;
random = type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)];
el = document.getElementById(el).value = random;
}

var setRandom4 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).value = random;
}

var setRandom5 = function(type,el){
var random;
random = type.subjects[randArr(type.subjects)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).value = random;
}

var setRandom6 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)];
el = document.getElementById(el).value = random;
}

var setRandom7 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).value = random;
}

var setRandom8 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).value = random;
}

var setRandom9 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).value = random;
}

var setRandom10 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).value = random;
}

var setRandom11 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).value = random;
}

var setRandom12 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).value = random;
}

var setRandom13 = function(type,el){
var random;
random = type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)];
el = document.getElementById(el).value = random;
}

</script>

<div id="inputHolder">
<input type="button" onClick="setRandom1(violence,'text');" value="Love" />
<input type="button" onClick="setRandom2(violence,'text');" value="Violence" />
<input type="button" onClick="setRandom3(violence,'text');" value="Social" />
<input type="button" onClick="setRandom4(violence,'text');" value="Love" />
<input type="button" onClick="setRandom5(violence,'text');" value="Violence" />
<input type="button" onClick="setRandom6(violence,'text');" value="Social" />
<input type="button" onClick="setRandom7(violence,'text');" value="Love" />
<input type="button" onClick="setRandom8(violence,'text');" value="Violence" />
<input type="button" onClick="setRandom9(violence,'text');" value="Social" />
<input type="button" onClick="setRandom10(violence,'text');" value="Love" />
<input type="button" onClick="setRandom11(violence,'text');" value="Violence" />
<input type="button" onClick="setRandom12(violence,'text');" value="Social" />
<br />
<br />
<textarea id="text" name="text" style="background:black;width:100%;height:150px;font-size:2em;font-family:garamond;color:#990000;text-transform: uppercase;"></textarea>
</div>
</center></p>
</body></html>

tivaelydoc
12-30-2008, 07:12 AM
If it's not too much trouble to ask, I wouldn't mind having it cleaned up. I lost my copy of dreamweaver, so I'm just going off the top of my head at the moment.

Nile
12-30-2008, 07:13 AM
Ok, but before I clean it, do you understand the usage of the 'violence' variable, and the other variables that you deleted(which was ok to do).

tivaelydoc
12-30-2008, 07:18 AM
Yea, I liked that part because it enables me to use a different set of variables. I just haven't got to changing the name yet.

When I finalize it, I might have a couple different sets of variables, so that could come in handy.

Nile
12-30-2008, 08:01 AM
Ok, here you go.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>Untitled Document</title>
<style type="text/css">
body {background-color: black}
</style>
</head>
<body spellcheck="false">
<p valign="middle">
<center>
<script type="text/javascript">
var violence = {
adverbs: ["Bill","Tom","Caroline","Macey"],
adjectives: ["stole from","punched","hit","stabbed"],
subjects: ["chatted with","went out with","called","emailed"],
presentverbs: ["made cookies for","kissed","hugged","broke up with","got together with"],
pastverbs: ["stole from","punched","hit","stabbed"],
nouns: ["chatted with","went out with","called","emailed"],
};
var sentences = new Array();
sentences[1] = function(type) { return type.subjects[randArr(type.subjects)]; },
sentences[2] = function(type) { return type.nouns[randArr(type.nouns)]; },
sentences[3] = function(type) { return type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)]; },
sentences[4] = function(type) { return type.adverbs[randArr(type.adverbs)] +" "+ type.nouns[randArr(type.nouns)]; },
sentences[5] = function(type) { return type.subjects[randArr(type.subjects)] +" "+ type.nouns[randArr(type.nouns)]; },
sentences[6] = function(type) { return type.adverbs[randArr(type.adverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)]; },
sentences[7] = function(type) { return type.adverbs[randArr(type.adverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.nouns[randArr(type.nouns)]; },
sentences[8] = function(type) { return type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.nouns[randArr(type.nouns)]; },
sentences[9] = function(type) { return type.adverbs[randArr(type.adverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)]; },
sentences[10] = function(type) { return type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)]; },
sentences[11] = function(type) { return type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)]; },
sentences[12] = function(type) { return type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)]; },
sentences[13] = function(type) { return type.adverbs[randArr(type.adverbs)] +" "+ type.adjectives[randArr(type.adjectives)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.pastverbs[randArr(type.pastverbs)] +" "+ type.subjects[randArr(type.subjects)] +" "+ type.presentverbs[randArr(type.presentverbs)] +" "+ type.nouns[randArr(type.nouns)]; };
var randArr = function(arr) {
arr = arr.length;
arr = Math.floor(Math.random()*arr);
return arr;
}
var setRandom = function(type,no,el) {
var random;
random = sentences[no](type);
el = document.getElementById(el).value = random;
}
</script>
<div id="inputHolder">
<input type="button" onclick="setRandom(violence,1,'text');" value="Love" />
<input type="button" onclick="setRandom(violence,2,'text');" value="Violence" />
<input type="button" onclick="setRandom(violence,3,'text');" value="Social" />
<input type="button" onclick="setRandom(violence,4,'text');" value="Love" />
<input type="button" onclick="setRandom(violence,5,'text');" value="Violence" />
<input type="button" onclick="setRandom(violence,6,'text');" value="Social" />
<input type="button" onclick="setRandom(violence,7,'text');" value="Love" />
<input type="button" onclick="setRandom(violence,8,'text');" value="Violence" />
<input type="button" onclick="setRandom(violence,9,'text');" value="Social" />
<input type="button" onclick="setRandom(violence,10,'text');" value="Love" />
<input type="button" onclick="setRandom(violence,11,'text');" value="Violence" />
<input type="button" onclick="setRandom(violence,12,'text');" value="Social" />
<br />
<br />
<textarea id="text" name="text" style="background:black;width:100%;height:150px;font-size:2em;font-family:garamond;color:#990000;text-transform: uppercase;"></textarea>
</div>
</body>
</html>

If you don't understand something, just ask. :D