<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Name Generators Blog &#187; script</title>
	<atom:link href="http://www.name-generators.com/tag/script/feed" rel="self" type="application/rss+xml" />
	<link>http://www.name-generators.com</link>
	<description>Blogging about name generators</description>
	<lastBuildDate>Sun, 04 Dec 2011 17:28:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to make binary to decimal conversion in JavaScript</title>
		<link>http://www.name-generators.com/javascript-2/how-to-make-binary-decimal-conversion-in-javascript.htm</link>
		<comments>http://www.name-generators.com/javascript-2/how-to-make-binary-decimal-conversion-in-javascript.htm#comments</comments>
		<pubDate>Sun, 31 Oct 2010 10:40:52 +0000</pubDate>
		<dc:creator>Niels</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[binary]]></category>
		<category><![CDATA[converter]]></category>
		<category><![CDATA[decimal]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.name-generators.com/?p=382</guid>
		<description><![CDATA[Conversion between binary and decimal is very easy in JavaScript.  This tutorial will show you how to make a binary to decimal converter and vice versa. But conversion from binary to hexadecimal is just as simple. JavaScript has some nice &#8230; <a href="http://www.name-generators.com/javascript-2/how-to-make-binary-decimal-conversion-in-javascript.htm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Conversion between binary and decimal is very easy in JavaScript.  This tutorial will show you how to make a binary to decimal converter and vice versa. But conversion from binary to hexadecimal is just as simple. JavaScript has some nice build in function that making it extremely easy to convert from one numeral system to another.</p>
<h3>Binary to decimal converter script</h3>
<p>Let first take a look at how you make a binary to decimal converter script:</p>
<pre lang="javascript">function convertBinary(){
   var binaryNumber = document.getElementById('binary').value;
   binaryNumber = parseInt(binaryNumber,2);
   var decimalNumber = binaryNumber.toString(10);
   alert(decimalNumber)
 }
</pre>
<p>First you need to get the input form the user. I assume you have made a input text filed with the ID=&#8221;binary&#8221; in your HTML.</p>
<p>Then you have to parse that input to an integer. This operation is very basic JavaScript but be aware the second parameter (radix) in the parseInt function. The radix is optional. A number (from 2 to 36) that represents the numeral system to be used. Using 2 as the radix tells JavaScript to parse it into the binary numeral system.</p>
<p>Finally we use JavaScript toString function to convert the number into a string. The parameter 10(again called radix in this function) tells Javascript, that we want to use the decimal numeral system in this conversion.</p>
<p>Now we just need to alert the converted number, and we are done. Very simple and very easy.</p>
<h3>Decimal to binary converter script</h3>
<p>And here&#8217;s how to make a decimal to binary converter script. This conversion is just as simple.</p>
<pre lang="javascript"> function convertDecimal(){
   var decimalNumber = document.getElementById('decimal').value;
   decimalNumber = parseInt(decimalNumber);
   var binaryNumber = decimalNumber.toString(2);
   alert(binaryNumber)
 }</pre>
<p>This decimal to binary converter script is basically the same as in the above. The only change is that we don&#8217;t need the second radix parameter to the parseInt function. JavaScript assume per default that we want to parse to integer using the decimal number system.</p>
<h3>How to make a Hexadecimal converter</h3>
<p>Just as simple as the 2 above examples. You just need to use the right radix in the 2 JavaScript functions as already explained. the radix in the Hexadecimal numeral system is 16.</p>
<h3>Finalization of the converter scripts</h3>
<p>Now you just need to put the JavaScript and HTML together. This can be done in a lot of ways. I have made an example of a <a title="Binary to decimal converter" href="http://www.name-generators.com/generators/binary-decimal-converter.html" target="_blank">Binary to Decimal converter</a>. Just right click and choose &#8220;view source&#8221; to view the code. You are of course welcome to copy the Binary to Decimal converter code and use as a base for your own experiments.</p>
<h3>Binary &#8211; Decimal resources</h3>
<p><a title="Binary numeral system at the Wiki" href="http://en.wikipedia.org/wiki/Binary_numeral_system" target="_blank">Binary numeral system</a>, <a title="Decimal numeral system at the Wiki" href="http://en.wikipedia.org/wiki/Decimal" target="_blank">Decimal numeral system</a> and <a title="Hexadecimal numeral system at the Wiki" href="http://en.wikipedia.org/wiki/Hexadecimal" target="_blank">Hexadecimal numeral system</a>. Great descriptions description of the Binary, Decimal and Hexadecimal numeral system at Wikipedia. Lots of facts about history,  representation, counting and calculating using the numeral systems.</p>
<p><a title="ParseInt at w3schools" href="http://www.w3schools.com/jsref/jsref_parseint.asp" target="_blank">parseInt at W3 schools</a>. W3 schools is a great place to learn basic JavaScript.</p>
<p><a title="Binary to decimal converter" href="../generators/binary-decimal-converter.html" target="_blank">Binary to Decimal converter</a>. An example script that makes both Binary to Decimal and Decimal to Binary conversions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.name-generators.com/javascript-2/how-to-make-binary-decimal-conversion-in-javascript.htm/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Use random vowels to make fantasy names</title>
		<link>http://www.name-generators.com/name-generators/use-random-vowels-to-make-fantasy-names.htm</link>
		<comments>http://www.name-generators.com/name-generators/use-random-vowels-to-make-fantasy-names.htm#comments</comments>
		<pubDate>Sat, 11 Sep 2010 18:51:13 +0000</pubDate>
		<dc:creator>Niels</dc:creator>
				<category><![CDATA[Name generator stuff]]></category>
		<category><![CDATA[fantasy names]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[vowels]]></category>

		<guid isPermaLink="false">http://www.name-generators.com/?p=273</guid>
		<description><![CDATA[One of the more simple ways to create new fantasy names is to take an ordinary name, change some of the letters until you find a good sounding combination. If we use the common name &#8220;Peter&#8221; as a base we &#8230; <a href="http://www.name-generators.com/name-generators/use-random-vowels-to-make-fantasy-names.htm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the more simple ways to create new fantasy names is to take an ordinary name, change some of the letters until you find a good sounding combination.</p>
<p>If we use the common name &#8220;Peter&#8221; as a base we could end up with names like &#8220;Patir&#8221; or &#8220;Petur&#8221;.  Both great fantasy names.</p>
<p>In this simple tutorial we will look at a script that will automate that  process and make  fantasy names by changing the vowels of a known name. Try the  demo here:  <a title="Fantasy names with letter change" href="../generators/fantasy-names-change-vowels.html" target="_blank">fantasy names with random vowels</a>.</p>
<h3>The change vowel script</h3>
<p>Here&#8217;s the full JavasScript random vowel function:</p>
<pre lang="javascript" line="1">function voweliseName(){
    if(document.getElementById("userName").value != ""){
        var name = document.getElementById("userName").value.toLowerCase();
	var newName = "";
	var vowels = ["a","e","i","o","u","y"]
	for(var i=0;i&lt;name.length;i++){
	    if(name.charAt(i) == "a"
		|| name.charAt(i) == "e"
		|| name.charAt(i) == "i"
		|| name.charAt(i) == "o"
		|| name.charAt(i) == "u"
		|| name.charAt(i) == "y"){
		newName = newName + vowels[parseInt(Math.random()*vowels.length)]
	    }else{
		newName = newName + name.charAt(i);
	    }
         }
	 alert("Your new name is: " + newName);
	 }else{
	    alert('Please type your name in the text box');
	 }
 }</pre>
<p>First we define our JavaScript function. Let&#8217;s call it vowelizeName(). Then we check if the user has made an input in the input field. If not we go to the end of the script and alert an error message.</p>
<p>Otherwise we get the input with the &#8220;getDocumentById(&#8220;userName&#8221;)and transform it to lowercase with the lowecase() function. Then we don&#8217;t need to check for both uppercase and lowercase vowels.</p>
<p>Now we define a variable to hold our new name, and an array that contains all the English vowels. Scandinavian and German readers might wanna expand the vowel list with special characters like æ, ø , å, ü, ä, ö etc. Just remember to add them in the check also.</p>
<p>Finally we are ready to start the name processing. We do that with a for loop. We run through the letters one by one with the charAt() function. This function gets the character at the position the parameters show. In this for loop we use &#8220;i&#8221; as a counter.</p>
<p>If the letter is a vowel we find a random integer and get a random vowel from the array corresponding to the random integer. Then we concatenate the letter to the newName variable. If the letter is a consonant we just concatenate it directly to the newName.</p>
<p>When the for loop has run through all the characters in the name, the new name is alerted.</p>
<p>Wanna know more about JavaScript.  <a title="JavaScript at W3 Schools" href="http://www.w3schools.com/js/default.asp" target="_blank">W3 schools JavaScript section</a> is the place to go.</p>
<h3>The HTML code to make the vowel script running</h3>
<p>Here&#8217;s the HTML code you need to make the vowel script running.</p>
<pre>&lt;input id="userName" onkeypress="if(event.keyCode==13)voweliseName()" type="text"/&gt;
&lt;input onclick="voweliseName()" type="button" value="Make fantasy name now"/&gt;</pre>
<p>We need 1 input field with the ID &#8220;username&#8221;, so the JavaScript can grab the user input. The onkeypress attribute checks if the enter key(the enterkey has the keyCode 13) is pressed. If so the voweliseName() is run. And then we need a ordinary button, where the function is called with the usual mouse click.</p>
<p>And that&#8217;s it. When we put it all together we have a full functional fantasy name generator.</p>
<h3>Try the fantasy name script</h3>
<p>I just run my own name through fantasy vowelizer.  One of the better fantasy names that came up was   &#8220;Nyals Gimbyrg&#8221;. Can&#8217;t imagine it much more fantazied than that. Pretty cool for an elvish name IMHO.</p>
<p>Give it a go your self and create <a title="Fantasy names with letter change" href="http://www.name-generators.com/generators/fantasy-names-change-vowels.html" target="_blank">fantasy names with randomized vowels</a>.</p>
<p>If you want more complex fantasy names go to the <a href="http://online-generator.com/name-generator/fantasy-name-generator.php">fantasy name generator</a>. Perfect fantasy names for all kind of role playing games.</p>
<p>If you get a cool name, please share it in the comments. <img src='http://www.name-generators.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.name-generators.com/name-generators/use-random-vowels-to-make-fantasy-names.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random name generator in Python</title>
		<link>http://www.name-generators.com/name-generators/random-name-generator-in-python.htm</link>
		<comments>http://www.name-generators.com/name-generators/random-name-generator-in-python.htm#comments</comments>
		<pubDate>Sat, 04 Sep 2010 19:25:52 +0000</pubDate>
		<dc:creator>Niels</dc:creator>
				<category><![CDATA[Name generator stuff]]></category>
		<category><![CDATA[name generator]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.name-generators.com/?p=254</guid>
		<description><![CDATA[In this short tutorial I will show you how to make a random name generator in Python. If you came here looking for some cool random names visit the online name generators. The name generator script Open IDLE which is &#8230; <a href="http://www.name-generators.com/name-generators/random-name-generator-in-python.htm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In this short tutorial I will show you how to make a random name generator in Python.</p>
<p>If you came here looking for some cool random names visit the online<strong> <a title="Name generators" href="http://online-generator.com/" target="_blank">name generators</a></strong>.</p>
<h3>The name generator script</h3>
<p>Open IDLE which is the Python supplied IDE or editor (Go to the bottom of the post to see, how you get started with Python).</p>
<p>Open a new window from the file menu and write the following name generator script into this window.</p>
<pre lang="python" line="1">def name_generator():
  import random
  color = ["Red","Blue","Black","White"]
  tool = ["Hammer","Drill","Cutter","Knife"]
  randomNumber1 = random.randrange(0,len(color))
  randomNumber2 = random.randrange(0,len(tool))
  name = color[randomNumber1] + " " + tool[randomNumber2]
  print(name)

name_generator()

(Be aware that copy-paste from the blog may give syntax errors!
 A correct indent is an important element Python syntax!)
</pre>
<p>Save it as name-generator.py.  Now you can run the python program by pressing F5.</p>
<h3>Name generator walk through</h3>
<p>Lets walk through the python script, line by line.</p>
<ol>
<li>In the first line we define our name generator function.</li>
<li>Then we import the random module, so we can call the random function later on.</li>
<li>In line define 2 arrays (color and tool) and asign values to them</li>
<li>Then we make 2 random numbers based on the length of our arrays. The randrage() function returns an integer in the range defined by the parameters. As parameters we use 0 and the len() function to count the numbers of words in the arrays.</li>
<li>In line 7 and 8 we make the final name and print it on the screen.</li>
<li>Finally we call the name generator function, we have just written.</li>
</ol>
<p>That&#8217;s all it takes to make a simple Python random name generator. When you this basic functionality it&#8217;s easy to experiment and develop the random name generator to suit your needs and wishes.</p>
<h3>Name generator inspiration</h3>
<p>For inspiration visit the <a title="Name generators" href="http://online-generator.com/" target="_blank">name generators</a> where you can find a lot of name generators in several genres. From random names over fantasy and nicknames to band and business names.</p>
<h3>Python Beginner guides and tutorials</h3>
<p>Python is a free scripting language running on all platforms from  Linux to Windows. Python is a relative easy programming language and a  name generator is a simple application so it&#8217;s a good place to start if  you wanna learn some programming.</p>
<p>If you haven&#8217;t Python installed at your computer you can download it at <a title="Download Python" href="http://www.python.org/download/" target="_blank">Python.org</a>. This name generator script is based on python 3.12, which is the newest stable version at the moment.</p>
<p>At python.org you can find an excellent <a title="Python tutorial" href="http://docs.python.org/py3k/tutorial/index.html" target="_blank">Python tutorial</a>. And you can find much more about how to use the <a title="Random module in Python" href="http://docs.python.org/py3k/library/random.html">Random function in Python</a>.</p>
<p>Or visit this <a title="Python beginner guide" href="http://wiki.python.org/moin/BeginnersGuide" target="_blank">beginner guide to Python</a> which contains lots of links and resources.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.name-generators.com/name-generators/random-name-generator-in-python.htm/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Choose random person</title>
		<link>http://www.name-generators.com/other-generators/choose-random-person.htm</link>
		<comments>http://www.name-generators.com/other-generators/choose-random-person.htm#comments</comments>
		<pubDate>Sun, 25 Jul 2010 08:44:09 +0000</pubDate>
		<dc:creator>Niels</dc:creator>
				<category><![CDATA[Other generators]]></category>
		<category><![CDATA[person]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[student]]></category>

		<guid isPermaLink="false">http://www.name-generators.com/?p=218</guid>
		<description><![CDATA[I made a little script that choose a random person from a list. The background is that I got this mail from a reader, who need to  choose a random student from his class to answer questions. Tom wrote: I &#8230; <a href="http://www.name-generators.com/other-generators/choose-random-person.htm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I made a little script that <strong>choose a random person</strong> from a list.</p>
<p>The background is that I got this mail from a reader, who need to  choose a random student from his class to answer questions.</p>
<p>Tom wrote:<br />
<em>I am a teacher and we have to randomly choose students to call and answer  questions.  Right now we use popsicle sticks with name on stick.  I would like to be  able to set up 4 classes,  type in the names of the students from the class and  have the app pick a name out of that class randomly.</em></p>
<p>Beside choosing persons randomly such a random app  also can be used to random pick all kinds of objects or items from a list. Script is programmed in JavaScript.</p>
<h3>Choose random person script</h3>
<p>Here&#8217;s a very simple but useful script, which choose a random student  from a list of names.</p>
<pre lang="javascript" line="1">function choose_student(){
    // Add your own student names to the class list
    var class_list =  ["Marge","Maggie","Lisa","Bart","Homer","Apu","Burns"];

    // Random numbers are made
    var randomNumber = parseInt(Math.random() * class_list.length);

    // Student are chosen from the class array with the random number
    var name = class_list[randomNumber];

    // Name is shown in alert box
    alert(name);
}</pre>
<ol>
<li>First you make an array (a list ) with the names of the persons you want to choose from</li>
<li>The Math.random() makes random numbers between 0 and 1. By multiplying it with the numbers of students of the list (found with the length function) and flooring it all with the parseInt() function, we will get a number between 0 and numbers of students in the class minus 1.</li>
<li>The person in the position of the random number is extracted from the list and saved in a variable. (the item in the first position in an array is called with the index number 0 like this: myArray[0])</li>
<li>Finally the chosen students name is shown in JavaScript alert box.</li>
</ol>
<p>And finally you just need to call the &#8220;choose random student&#8221;-function from your HTML.</p>
<pre>&lt;input type="button" value="Chose Random Student" onclick="choose_student()" /&gt;</pre>
<h3>Download example script</h3>
<p>You can download an example <a title="Choose random person script" href="http://www.name-generators.com/download/choose-random-person-script.zip">choose random person script</a> here. In the script you can find both the above pick random person script and the pick random student script I made for Tom. All is integrated in a complete HTML file ready to launch in your favorite browser.</p>
<p>The example script is integrated roughly into my name generator script, but it should give a good overview over how to accomplish the task of picking random persons from simple lists, and how to integrate a simple random application into a HTML page.</p>
<h3>Is it the above method truly random?</h3>
<p>In short no, but semi randomness is sufficient and adequate for the purpose of selecting random persons for none scientific reasons.</p>
<p>Read more about true <a title="Random numbers and random names" href="http://www.name-generators.com/name-generators/random-numbers-and-random-names.htm">random numbers and names</a>.</p>
<div style="margin: 12px 0px; font-family: arial; color: #333333; background: none repeat scroll 0% 0% #ffffff; border: 4px solid #e5e5e5; width: 100%; clear: left;">
<div class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px; background-color: #ffffff;">
<div style="border-bottom: 1px solid #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee; background-image: url(http://clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;"><a title="see clips that are hot right now" href="http://clipmarks.com/clip-to-blog/"><img style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float: none;" src="http://content.clipmarks.com/blog_embed/6976dc14-ee2e-4322-ac1f-f85642294215/4905F106-063A-401C-8631-392E2E49652A/" border="0" alt="" width="19" height="19" /></a>clipped from <a style="font-size: 11px;" title="http://web.archive.org/web/20011027002011/http://dilbert.com/comics/dilbert/archive/images/dilbert2001182781025.gif" href="http://web.archive.org/web/20011027002011/http://dilbert.com/comics/dilbert/archive/images/dilbert2001182781025.gif">web.archive.org</a></div>
<blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://web.archive.org/web/20011027002011/http://dilbert.com/comics/dilbert/archive/images/dilbert2001182781025.gif">
<div><img src="http://content9.clipmarks.com/blog_cache/web.archive.org/img/405B2A78-5499-474D-89B9-17F420F175C5" alt="http://web.archive.org/web/20011027002011/http://dilbert.com/comics/dilbert/archive/images/dilbert2001182781025.gif" /></div>
</blockquote>
</div>
<div style="margin: 0px 6px 6px 4px;">
<table style="font-size: 11px; border-spacing: 0px; padding: 0px;" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td style="background: transparent; border-width: 0px; padding: 0px;"></td>
<td style="background: none repeat scroll 0% 0% transparent; border-width: 0px; padding: 0px; width: 107px;" width="107" align="right"><a title="blog or email this clip" href="http://clipmarks.com/share/4905F106-063A-401C-8631-392E2E49652A/blog/"><img style="border-width: 0px; padding: 0px; margin: 0px;" src="http://content6.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" /></a></td>
</tr>
</tbody>
</table>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.name-generators.com/other-generators/choose-random-person.htm/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Name generator script</title>
		<link>http://www.name-generators.com/name-generators/name-generator-script.htm</link>
		<comments>http://www.name-generators.com/name-generators/name-generator-script.htm#comments</comments>
		<pubDate>Tue, 11 May 2010 17:38:10 +0000</pubDate>
		<dc:creator>Niels</dc:creator>
				<category><![CDATA[Name generator stuff]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[name]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.name-generators.com/?p=171</guid>
		<description><![CDATA[I have made a  complete name generator script to download and use as your own. The script contains a full functional HTML page with all necessary JavaScript code, HTML and CSS, and can be run in any browser. The name &#8230; <a href="http://www.name-generators.com/name-generators/name-generator-script.htm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have made a  complete name generator script to download and use as your own. The script contains a full functional HTML page with all necessary JavaScript code, HTML and CSS, and can be run in any browser.</p>
<p>The name generator script is a complete do-it-yourself name generator! Ready to run with or without changes. The script is a simplified version one of the one I use at all my <a title="Name generators" href="http://online-generator.com/" target="_blank">name generators</a>.</p>
<p>The script is thoroughly explained and commented in the download file. So it is very easy  to work with for everybody, even for beginners to web programming. If you like further explanation on how the script works visit my <a title="How to make a name generator tutorial" href="http://www.name-generators.com/name-generators/how-to-make-name-generator.htm" target="_blank">How to make a name generator</a> tutorial, where i you through a only slightly more simple generator script.</p>
<p>To get up and running just download the script, change the text and change the word arrays to your likings.  And you got yourself your own personal name generator.</p>
<h3 style="font-size: 20px; margin-bottom: 10px;">How to use the name generator script</h3>
<h3>Getting started</h3>
<p>Download the <a href="http://www.name-generators.com/download/name-generator-script.zip">name-generator-script.zip</a>.</p>
<p>Or just visit the <a title="Name Generator Script demo" href="http://www.name-generators.com/download/name-generator-script-demo.html" target="_blank">name generator script demo</a>, right click the page. Select view source. Copy the source to a text-editor.<br />
Save is at generator.html.</p>
<h3>How to run it</h3>
<p>It&#8217;s easy. Just open the html file with your favorite browser.</p>
<h3>How to edit it</h3>
<p>To edit this page open it with a text editor with syntax highlighting. I&#8217;ll strongly recommend <a href="http://notepad-plus.sourceforge.net/">notepadd++</a> a free, fast and flexible text editor, I also use myself.</p>
<h3>Name Generator FAQ</h3>
<p>No one yet. Guess the code must be  self-explanatory. <img src='http://www.name-generators.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   Well seriously&#8230; if you need help just ask your questions below. I&#8217;ll try my best to help you.</p>
<p>EDIT: Well now the comments works as a FAQ.  Please check them to see if you question already has been asked.</p>
<h3>How to get visitors on your new name generator</h3>
<p>If you make a cool name generator, I might wanna make a review of it. Just write a comment and I&#8217;ll look into it.</p>
<h3>How to host your new name generator</h3>
<p>There&#8217;s several ways to host your new name generator.</p>
<p>If you want your own domain name there&#8217;s a lot of companies to choose from. If you stick to some of the bigger companies the hosting is often very reliable.</p>
<p>The price level is often low and sometimes you can get a free domain name with the hosting plan.</p>
<p>But you can also find free hosting, if you don&#8217;t want your own domain.  Just make sure the service you choose supports the running of JavaScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.name-generators.com/name-generators/name-generator-script.htm/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>How to make a name generator</title>
		<link>http://www.name-generators.com/name-generators/how-to-make-name-generator.htm</link>
		<comments>http://www.name-generators.com/name-generators/how-to-make-name-generator.htm#comments</comments>
		<pubDate>Sat, 08 May 2010 18:26:05 +0000</pubDate>
		<dc:creator>Niels</dc:creator>
				<category><![CDATA[Name generator stuff]]></category>
		<category><![CDATA[name generator]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.name-generators.com/?p=143</guid>
		<description><![CDATA[In this tutorial I&#8217;ll show how to make a simple name generator. A sort of  &#8220;build your own name generator&#8221; to experiment with. You just need to add your own word lists and you&#8217;re up and running.  But you can &#8230; <a href="http://www.name-generators.com/name-generators/how-to-make-name-generator.htm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I&#8217;ll show how to make a simple name generator. A sort of  &#8220;build your own name generator&#8221; to experiment with. You just need to add your own word lists and you&#8217;re up and running.  But you can expand and modify the  name generator code to your own likings   and abilities.</p>
<p>The name generator tutorial is very simple and are aimed at absolute beginners in web programming.</p>
<p>But enough talk, here is some name generator code that makes superhero names:</p>
<pre lang="javascript">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);
}</pre>
<p>The script is a simplified version of the one I use to make <a title="Superhero names" href="http://online-generator.com/name-generator/superhero-name-generator.php" target="_blank">superhero names</a> with my superhero generator.</p>
<h3 style="font-size: 20px; margin-bottom: 10px;">The name generator piece by piece</h3>
<h3>The arrays</h3>
<p>The most important part of  the name generator is the word lists. The more words in the list the more variety in the output. So the first part to do is to create a couple of arrays holding all our cool words:</p>
<pre lang="javascript">var adjectives = ["cool","masked","bloody","lame"];
var animals = ["hamster","moose","lama","duck"]</pre>
<p>To retrieve data  from the list we call the name of array with the count of the word as a parameter in a square bracket.  Be aware that counting in programming almost always starts at zero and not at 1.</p>
<p>So adjectives[0] is cool and  animals[1] gives moose</p>
<h3>Randomness</h3>
<p>We of course want random names, so we need to replace the hard coded numbers with random numbers. In our case numbers between 0 and 3 because we have 4 words in our lists. Instead of counting the words ourself, we do that we let the JavaScript length function do the counting. Then we multiply it with a random floating-point number between 0 and 0.9999999999999. Finally we use the parseInt funktion to make the floating-point number into a integer.</p>
<p>All sounds a bit complicated but code wise  it&#8217;s  quite easy.</p>
<pre lang="javascript">randomNumber1 = parseInt(Math.random() * adjectives.length);
randomNumber2 = parseInt(Math.random() * animals.length);</pre>
<h3>The output</h3>
<p>The most simple way to output the name is using the alert function. I use it only to check the generated name cause,  the alert box is  very annoying. So just delete the line, when the code below is up an running.</p>
<p>We will use 7 extra lines to integrate the result into the web page in a more natural way.</p>
<p>But before we begin you need to make an empty div tag in your HTML:</p>
<p>&lt;div id=&#8221;placeholder&#8221;&gt;&lt;/div&gt;</p>
<p>And here are the 7 lines that write the result in the page..</p>
<pre lang="javascript">if(document.getElementById("result")){
  document.getElementById("placeholder").removeChild(document.getElementById("result"));
}

element = document.createElement("div");
element.setAttribute("id", "result");
element.appendChild(document.createTextNode(name));
document.getElementById("placeholder").appendChild(element);</pre>
<p>In short it works like this:</p>
<ol>
<li>If there&#8217;s already a result it is removed</li>
<li>Then a new div element to hold the result  is created</li>
<li>The name is added as a text node</li>
<li>Finally the element is appended to a placeholder in the HTML.</li>
</ol>
<p>When this part works, you can delete the alert(name) from the script.</p>
<h3>Putting it all together</h3>
<p>The generator function can either be included in the head of the HTML document or you can place it in a external JavaScript file.</p>
<p>Now you can call the function from your HTML page.  I always do it 2 places. First in the body tag with an onload event. The generator function then also runs when the page is loaded.</p>
<p>&lt;body onload=&#8221;generator()&#8221;&gt;</p>
<p>And then I also call the JavaScript function on a button:</p>
<p>&lt;input type=&#8221;button&#8221; onclick=&#8221;generator()&#8221; /&gt;</p>
<h3>Download the name generator script</h3>
<p><a title="Download name generator script as zip file" href="http://www.name-generators.com/name-generators/download/name-generator-script.zip">Download name generator script here</a> and read the description of <a title="Name generator script" href="http://www.name-generators.com/name-generators/name-generator-script.htm">how to make the name generator script work</a>.</p>
<h3>Extra funcionality</h3>
<p>The random functions in this guide is very simple. At some time you&#8217;ll probably want to make more complex and interesting names. Here you can see <a title="Make more complex random names" href="http://www.name-generators.com/name-generators/complex-random-names.htm">how to make more complex random names</a>.</p>
<p>On all of my name generators I also have a save list, which saves all the generated names to a list. Read here <a title="Add a save list to name generator" href="http://www.name-generators.com/name-generators/save-name-generator-names.htm">how to add a save list to the name generator</a>.</p>
<h3>Want a review of your name generator?</h3>
<p>Write a comment if  you make a cool name generator with this script. I might very well  write a review of it.  <img src='http://www.name-generators.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Also remember to visit my name generators to see  how I make <a title="Superhero name" href="http://online-generator.com/name-generator/superhero-name-generator.php" target="_blank">superhero names</a> with the superhero generator.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.name-generators.com/name-generators/how-to-make-name-generator.htm/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>

