Difference between revisions of "User:Sasuke/monobook.js"

From FreekiWiki
Jump to navigation Jump to search
(trying a word genorator)
 
m (more random word gen stuff)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
// Use the following variable to specify  
+
<FORM NAME="WordForm">
// the number of random words
+
<INPUT TYPE=TEXT SIZE=10 NAME="WordBox"><BR>
 +
<INPUT TYPE=BUTTON onClick="PickRandomWord(document.WordForm)"
 +
VALUE="Click Here to Get a Random Word">
 +
</FORM>
 +
 
 +
 
 +
 
 +
// Use the following variable to specify the number of random words  
 +
 
 
var NumberOfWords = 7
 
var NumberOfWords = 7
  
 
var words = new BuildArray(NumberOfWords)
 
var words = new BuildArray(NumberOfWords)
  
// Use the following variables to  
+
// Use the following variables to define your random words:
// define your random words:
+
 
 
words[1] = "Superb"
 
words[1] = "Superb"
 
words[2] = "Excellent"
 
words[2] = "Excellent"

Latest revision as of 16:26, 5 October 2006

<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>



// Use the following variable to specify the number of random words 

var NumberOfWords = 7

var words = new BuildArray(NumberOfWords)

// Use the following variables to define your random words:

words[1] = "Superb"
words[2] = "Excellent"
words[3] = "Good"
words[4] = "Fair"
words[5] = "Medicore"
words[6] = "Poor"
words[7] = "Terrible"

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]
}