Maple
Administrator
A Maple Leaf is ur Admin.
Posts: 104
|
Post by Maple on Mar 9, 2011 23:48:35 GMT -5
function generator(){ // Add your own words to the wordlist. Be carefull to obey the showed syntax var adjectives = ["Cool","Masked","Bloody","Lame"] var animals = ["Hamster","Moose","Lama","Duck"] // Random numbers are made var randomNumber1 = parseInt(Math.random() * adjectives.length); var randomNumber2 = parseInt(Math.random() * animals.length); var name = adjectives[randomNumber1] + " " + animals[randomNumber2]; alert(name); //Delete this when the below works //If there's already a name it is removed if(document.getElementById("result")){ document.getElementById("placeholder").removeChild(document.getElementById("result")); } // A div element is created to show the generated name. //The Name is added as a textnode. Textnode is added to the placeholder. var element = document.createElement("div"); element.setAttribute("id", "result"); element.appendChild(document.createTextNode(name)); document.getElementById("placeholder").appendChild(element); }
|
|