Archive

Archive for July, 2010

Choose random person

July 25th, 2010 Niels No comments

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

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.

Choose random person script

Here’s a very simple but useful script, which choose a random student  from a list of names.

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);
}

  1. First you make an array (a list ) with the names of the persons you want to choose from
  2. 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.
  3. 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])
  4. Finally the chosen students name is shown in JavaScript alert box.

And finally you just need to call the “choose random student”-function from your HTML.

<input type=”button” value=”Chose Random Student” onclick=”choose_student()” />

Download example script

You can download an example choose random person script 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.

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.

Is it the above method truly random?

In short no, but semi randomness is sufficient and adequate for the purpose of selecting random persons for none scientific reasons.

Read more about true random numbers and names.

clipped from web.archive.org
http://web.archive.org/web/20011027002011/http://dilbert.com/comics/dilbert/archive/images/dilbert2001182781025.gif
blog it

Band name widget

July 23rd, 2010 Niels No comments

Band name widget at Australian band site entertainya

I was contacted by Aladdin from the  Australian band site entertainya. Aladdin wanted a band name  widget to spice up entertainya.com.au.

Alladin wrote:
My Name is Aladdin, I run and own an Australian online music and entertainment called entertainya. I have been on the hunt for something fresh and exciting to add to my site as i have 1000′s of musicians browsing everyday.
I came across your project and would love for you to consider allowing me to integrate your band name generator onto my site.

I thought the idea sounded exiting and started to develop a band name widget. The band name widget gave the idea to make a free  name generator widget.

Band name generator

The band name generator  widget is a  full copy of the band name generator. Same amount of band name combinations and with a 100%  functionality.

You can see the band widget and how seamless  it integrates with the site.  Entertainya.com.au is based on a  joomla cms.  The band generator code is run locally on the client, so it will work with all blogs, cms as well as ordinary html pages.

Behind the band widget

The band name widget is programmed in JavaScript, HTML and CSS, and Alladin  just needed to add a single line of JavaScript to include on his website.

The widget is compressed to minimize download time, and of course follows the w3.0rg standards for proper HTML and validates as XHTML 1.1.

Do you want a cool name widget too?

Do you want a similar or other specialized cool name widget on your site, blog or  favorite forum? Check out this free name generator widget.

Are you looking for a different kind of cool name widget? Please contact me and let’s see if we can work out something.

Other ways to get a name generator

How to make a name generator

Name generator script

Name generator widget

July 12th, 2010 Niels 4 comments

I continue to give away stuff.  This time it’s a name generator widget.

The name generator widget integrates seamlessly with the web site. The widget contains all the necessary code to run very easily on a web page. Just add a single line of code to your page.

The name generator widget makes code names, that can be used in various ways.  Use the  widget to make code names for bands, projects, blog names etc.

See how the widget works at my sidebar. —–>

How to install the widget

Just insert this line of simple  code, where you want the  name generator to run, and you got a fully functional name generator on your site.

<script type=”text/javascript” src=”http://name-generators.com/widgets/name-generator-widget-beta.js”></script>

The widget takes care of the rest. From name generation to styling.

How to customize the name widget.

Use firebug or other developer tool to see the unique id’s and classes on  all elements.  Just add these to your style sheet with the styles you want. In this way it’s easy to add background images or cool buttons to the widget.

Name widget specs

The widget is programmed in JavaScript. It is minified to minimize the load time for your users.

The name widget  works crossbrowser. It is tested in Firefox, Internet Explorer 7+8, Opera and Chrome.

It follows the XHTML standarad set by the w3.org and validate as XHTML 1.1.

Do you want another name widget?

Do you want a business, superhero or maybe a fantasy name widget on your site, blog or  favorite forum?

Please contact me and let’s see if we can work out something. I’m always interested in some serious text link cooperation. ;)

For another working example check this band name generator widget.

Other free name generator stuff

Also remember to check out the:

How to make a name generator

Name generator script