Paul McFedries' Web Home


Random Word Generator

The scripts on this page generate a random word from a list of 10-letter words. Try it:




Here are the instructions:
  1. The script uses a text box to display the random words. Use the following form:
        <FORM NAME="WordForm">
        <INPUT TYPE=TEXT SIZE=10 NAME="WordBox"><BR>
        <INPUT TYPE=BUTTON onClick="PickRandomWord(document.WordForm)" 
        VALUE="Click Here to Get a Random Word">
        </FORM>
    
  2. Copy everything between the <SCRIPT> and </SCRIPT> tags and insert this between the </HEAD> and <BODY> tags.
  3. You have to define the number of random words you want to use by altering the value in the following line:
        var NumberOfWords = 28
    
  4. You define your messages by editing the following lines:
        words[1] = "czarevitch"
        words[2] = "brightwork"
        words[3] = "verkrampte"
        etc.
    
Here's the full script:
<SCRIPT LANGUAGE="JavaScript">
<!--
// Use the following variable to specify 
// the number of random words
var NumberOfWords = 28

var words = new BuildArray(NumberOfWords)

// Use the following variables to 
// define your random words:
words[1] = "czarevitch"
words[2] = "brightwork"
words[3] = "verkrampte"
words[4] = "protectrix"
words[5] = "nudibranch"
words[6] = "grandchild"
words[7] = "newfangled"
words[8] = "flugelhorn"
words[9] = "mythologer"
words[10] = "pluperfect"
words[11] = "jellygraph"
words[12] = "quickthorn"
words[13] = "rottweiler"
words[14] = "technician"
words[15] = "cowpuncher"
words[16] = "middlebrow"
words[17] = "jackhammer"
words[18] = "triphthong"
words[19] = "wunderkind"
words[20] = "dazzlement"
words[21] = "jabberwock"
words[22] = "witchcraft"
words[23] = "pawnbroker"
words[24] = "thumbprint"
words[25] = "motorcycle"
words[26] = "cryptogram"
words[27] = "torchlight"
words[28] = "bankruptcy"

function BuildArray(size){
    this.length = size
    for (var i = 1; i <= size; i++){
        this[i] = null}
    return this
}

function PickRandomWord(frm) {
    // Generate a random number between 1 and NumberOfWords
    var rnd = Math.ceil(Math.random() * NumberOfWords)

    // Display the word inside the text box
    frm.WordBox.value = words[rnd]
}
//-->
</SCRIPT>

Copyright © 1995 - 2014 Paul McFedries and Logophilia Limited