We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Random Name Generator
Topic Started: Mar 30 2012, 07:35 PM (1,400 Views)
laltri
Member
[ * ]
This is a simple name generator. There isn’t much practical application but it might be good for forum roleplaying games.

Preview: http://w11.zetaboards.com/laltrisplayground/pages/namegen/
Create a new web page and copy the following code into the page content. You can change the names in the "MaleForename", "FemaleForename" and "Surname" arrays and add as many names to them as you desire.

Code:
 
<script type="text/javascript">

var MaleForename = new Array("Male Name 1","Male Name 2","Male Name 3")
var FemaleForename = new Array("Female Name 1","Female Name 2","Female Name 3")
var Surname = new Array("Surname 1", "Surname 2", "Surname 3")

var r=0
var i=0

function RandomName()
{
j=Math.floor(Math.random() * Surname.length);
if(document.NAMEIT.GENDER.options[1].selected == true)
{
i=Math.floor(Math.random() * FemaleForename.length);
document.NAMEIT.NAME.value=FemaleForename[i] + " " + Surname[j]
}
else
{
i=Math.floor(Math.random() * MaleForename.length);
document.NAMEIT.NAME.value=MaleForename[i] + " " + Surname[j]
}
}
</script>
<table border="1" cellpadding="0" cellspacing="0" bgcolor="#E4E4E4" bordercolor="#808080">
<tr>
<td>
<h2 align="center"><font face="Arial" size="1"><br>
</font><font face="Arial" size="3">Random Name Generator</font></H2>
<center>
<form name="NAMEIT">
<table>
<tr>
<td align="right" valign="top"><b><font face="Arial" size="2"> Gender:</font></b></td>
<td valign="top"><font face="Arial" size="2"><select name="GENDER" SIZE="1"> <option value="Male">Male
</option> <option value="Female">Female</option></select>
</font>
</td>
<td align="right" valign="top"><b><font face="Arial" size="2"> You look like a: </font></b></td>
<td valign="top"><font face="Arial" size="2"><input type="TEXT" name="NAME" size="20"></font></TD>
</tr>
</table>
<p align="center"><input type="button" name="btnGen" value="FIRE FIRE FIRE"
onclick="RandomName()"></p>
</form>
</center>
</td>
</tr>
</table>


Edited by laltri, Mar 30 2012, 08:00 PM.
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
You need to use the code tags or the nocode tags so the 'BBCode' won't be parsed.
Online Profile Quote Post Goto Top
 
laltri
Member
[ * ]
Cory
Mar 30 2012, 07:40 PM
You need to use the code tags or the nocode tags so the 'BBCode' won't be parsed.
Under normal circumstances I would, however there aren’t any BB codes in the quoted code (excluding the colour tags which were intended to be parsed) so it shouldn’t matter too much, and I wanted to highlight the name arrays so that people can see where they need to edit quicker. Thanks for the feedback.
Edited by laltri, Mar 30 2012, 07:45 PM.
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Code:
 
document.NAMEIT.NAME.value=FemaleForename[i] + " " + Surname[j]
Code:
 
document.NAMEIT.NAME.value=MaleForename[i] + " " + Surname[j]
Sorry, I suppose I should have been more clear. The identifier ([i]) is parsing, making most of the coding italic, and the identifier has disappeared since it's being parsed, thus the code won't work when copied.
Online Profile Quote Post Goto Top
 
laltri
Member
[ * ]
Cory
Mar 30 2012, 07:49 PM
Code:
 
document.NAMEIT.NAME.value=FemaleForename[i] + " " + Surname[j]
Code:
 
document.NAMEIT.NAME.value=MaleForename[i] + " " + Surname[j]
Sorry, I suppose I should have been more clear. The identifier ([i]) is parsing, making most of the coding italic, and the identifier has disappeared since it's being parsed, thus the code won't work when copied.
Oops, good call. I’ll sort it, thanks.
Offline Profile Quote Post Goto Top
 
The Syndicate
Member Avatar
Member
[ *  * ]
Awesome man.

Could this be made more advanced? IE more drop downs:

Gender: Male, Female
Relation: Jedi/Sithlord, Ninja, Commoner, Timelord etc etc etc

IF Male & Jedi are checked Then name = Obi Wan (Surname) / Yoda (Surname)
IF Female & Sith are checked Then name = Miss Darth (Surname)
If Male & Timelord are checked Then name = Dr (Surname) Who?

Lots of fun to be had with this :D Just wanna know how to make it more advanced as my coding skills are close to zero. Even a guide on doing this would be sweet. Possibilities would be endless.
Offline Profile Quote Post Goto Top
 
Yarott
Member
[ * ]
The Syndicate
Apr 6 2012, 10:29 PM
Awesome man.

Could this be made more advanced? IE more drop downs:

Gender: Male, Female
Relation: Jedi/Sithlord, Ninja, Commoner, Timelord etc etc etc

IF Male & Jedi are checked Then name = Obi Wan (Surname) / Yoda (Surname)
IF Female & Sith are checked Then name = Miss Darth (Surname)
If Male & Timelord are checked Then name = Dr (Surname) Who?

Lots of fun to be had with this :D Just wanna know how to make it more advanced as my coding skills are close to zero. Even a guide on doing this would be sweet. Possibilities would be endless.
Indeed! Those additions would be pretty sweet!
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · ZetaBoards Codes & Modifications · Next Topic »
Add Reply