Changes

Jump to: navigation, search

Chapters

154 bytes added, 16:48, 14 June 2011
no edit summary
<html>
<script>
var people chapters = new Array();function personchapter(firstNamechapterName, lastNamefoundingDate, agelocation, url) { this.FirstName ChapterName = firstNamechapterName; this.LastName FoundingDate = lastNameparseInt(parseFloat(foundingDate)); this.Age Location = location; this.URL = parseInt(parseFloat(age))url;
}
function drawArray(form) {
var v = "<table style='width:100%;'>"; for (var i=0; i<peoplechapters.length; i++) { v += people"<tr><td><a href='" + chapters[i].FirstName URL + " '>" + peoplechapters[i].LastName ChapterName + " (</a></td><td>" + chapters[i].FoundingDate + "</td><td>" + peoplechapters[i].Age Location + ")<br>";
}
document.getElementById('list').innerHTML = v+ "</table>"
}
window.onload = function(){
peoplechapters[peoplechapters.length++] = new personchapter("NickAlpha Deuteron", 1870, "WimsattMonmouth College, Monmouth, IL", 22"http://wiki.kappakappagamma.org/index.php/Alpha");peoplechapters[peoplechapters.length++] = new personchapter("JeanBeta", 1871, "DavisSt. Mary's School, Knoxville, IL", 50"http://wiki.kappakappagamma.org/index.php/Beta");peoplechapters[peoplechapters.length++] = new personchapter("ShawnGamma", 1872, "LongSmithson College, Logansport, IN", 35"http://wiki.kappakappagamma.org/index.php/Gamma");
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 sortByFirstNamesortByChapterName(a, b) { var x = a.FirstNameChapterName.toLowerCase(); var y = b.FirstNameChapterName.toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
function sortByLastNamesortByLocation(a, b) { var x = a.LastNameLocation.toLowerCase(); var y = b.LastNameLocation.toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
return ((x < y) ? -1 : ((x > y) ? 1 : sortByFirstName(a, b)));
}
function sortByAgesortByFoundingDate(a, b) { var x = a.AgeFoundingDate; var y = b.AgeFoundingDate;
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
function sortArray(form, column) {
if (peoplechapters.length == 0) {
alert("Please add one or more people before sorting!");
return false;
switch (column) {
case 1 :
peoplechapters.sort(sortByFirstNamesortByChapterName);
break;
case 2 :
peoplechapters.sort(sortByLastNamesortByFoundingDate);
break;
case 3 :
peoplechapters.sort(sortByAgesortByLocation);
break;
case 4 :
peoplechapters.sort(sortByLastNameThenFirst);
break;
}
// -->
</script>
<table style='width:100%'><tr><td><div onclick="sortArray(document.forms['Demo'], 1)">Chapter Name</div></td><td><div onclick="sortArray(document.forms['Demo'], 2)">Founding Date</div></td><td><div onclick="sortArray(document.forms['Demo'], 3)">Sort by AgeLocation</div></td></tr></table></html>
----

Navigation menu