I worked it out this way, put this in the body of your page:
Code:
<script type="text/javascript">
//Randomizing Unit Courtesy of Mike Winter as seen at:
//http://www.dynamicdrive.com/forums/showthread.php?p=8442
function random(n) {
return Math.floor((Math.random() % 1) * n);
}
Array.prototype.shuffle = function() {var i = this.length;
while(i--) {this.swap(i, random(i + 1));}
};
Array.prototype.swap = function(x, y) {
var t = this[x]; this[x] = this[y]; this[y] = t;
};
//End Randomizing Unit
var endSen=''
sens=new Array();
//set sentences below
sens[0]="five words in a row"
sens[1]="fish do not use cars"
sens[2]="birds are on the fly"
sens[3]="animals have many friends too"
sens[4]="who asked you the question"
for (var i_tem = 0; i_tem < sens.length; i_tem++){
sens[i_tem]=sens[i_tem].split(' ')
endSen+=sens[i_tem][random(5)]+' '
}
endSen=endSen.split(' ')
endSen.shuffle();
endSen=endSen.join(' ')
if(endSen.charAt(0)==' ')
endSen=endSen.substr(1)
endSen=endSen.charAt(0).toUpperCase()+endSen.substr(1)
document.write(endSen+'.')
</script>
Bookmarks