Changes

Jump to: navigation, search

Chapters

2,262 bytes added, 14:45, 14 June 2011
no edit summary
List of Kappa Kappa Gamma chapters founded in 1870 to present date:
<html>
<script>
var people = new Array();
function person(firstName, lastName, age) {
this.FirstName = firstName;
this.LastName = lastName;
this.Age = parseInt(parseFloat(age));
}
function drawArray(form) {
var v = "";
for (var i=0; i<people.length; i++) {
v += people[i].FirstName + " " + people[i].LastName + " (" + people[i].Age + ")<br>";
}
document.getElementById('list').innerHTML = v
}
window.onload = function(){
people[people.length++] = new person("Nick", "Wimsatt", 22);
people[people.length++] = new person("Jean", "Davis", 50);
people[people.length++] = new person("Shawn", "Long", 35);
drawArray();
 
}
function addToArray(form) {
if (form.FirstName.value == "") {
alert("Please enter the first name!");
form.FirstName.focus();
return false;
}
if (form.LastName.value == "") {
alert("Please enter the last name!");
form.LastName.focus();
return false;
}
if (form.Age.value == "") {
alert("Please enter the age!");
form.Age.focus();
return false;
}
people[people.length++] = new person(form.FirstName.value, form.LastName.value, form.Age.value);
form.FirstName.value = "";
form.LastName.value = "";
form.Age.value = "";
drawArray(form);
}
function sortByFirstName(a, b) {
var x = a.FirstName.toLowerCase();
var y = b.FirstName.toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
function sortByLastName(a, b) {
var x = a.LastName.toLowerCase();
var y = b.LastName.toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
function sortByLastNameThenFirst(a, b) {
var x = a.LastName.toLowerCase();
var y = b.LastName.toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : sortByFirstName(a, b)));
}
function sortByAge(a, b) {
var x = a.Age;
var y = b.Age;
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
function sortArray(form, column) {
if (people.length == 0) {
alert("Please add one or more people before sorting!");
return false;
}
switch (column) {
case 1 :
people.sort(sortByFirstName);
break;
case 2 :
people.sort(sortByLastName);
break;
case 3 :
people.sort(sortByAge);
break;
case 4 :
people.sort(sortByLastNameThenFirst);
break;
}
drawArray(form);
}
// -->
</script>
<div onclick="sortArray(document.forms['Demo'], 3)">Sort by Age</div></html>
----

Navigation menu