Blips
02-12-2005, 09:30 PM
i cant seem to get this to work. What is supposed to happen is that the person puts in a max of 10 names to the browser. It should then make the full name lower case and then make the first letter of each part of the name capital. It should then display the names in a list.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<H2><center>HOwdy Hoe!</center></H2>
<h3>Here is a small list of names for no reason at all ??</h3>
<br>
<br>
<script LANGUAGE="javascript" type="text/javascript">
/* Variables */
names = new Array(10);
names_sorted = new Array(10);
proper_case = new Array();
names_split = new Array();
converter = new Array();
first_char = new Array();
rest_of_string = new Array();
names_compile = new Array();
names_final = new Array();
i = 0
/* End of Variables */
/* Main Loop */
do {
next = window.prompt("enter something BIATCH");
/* If there are any chars in "next" continue and assigne value to names[i] */
if (next > " ") names[i] = next;
/* Splits names[i] and assigns the value to names_split */
names_split[i] = names[i].split(" ");
/* Takes the strings and converts them to lower case and gives them to proper_case */
for (x = 0; x < (names_split.length + 1); x++){
proper_case[x] = names_split[x].toLowerCase();
}
for (y = 0; x < (proper_case.length + 1); y++) {
/* Gives the first character of each string to converter[y] */
converter[y] = proper_case[y].charAt(0);
/* Converts each first character to its upper case form */
first_char[y] = converter[y].toUpperCase();
/* gives the rest of the string to rest_of_string[y] */
rest_of_string[y] = proper_case[y].substring(1, proper_case[y].length);
}
for (z = 0; z < (first_char.length + 1); z++){
/* puts each split back together and gives them to names_compile */
names_compile[z]=(first_char[z] + rest_of_string[z]);
}
/* Joins the names back together */
names_final[i] = names_compile.join(" ");
i++;
}
while (next > " " && i > 10);
document.write("<h4>" + (names_final.length) + " names entered.</h4>");
document.write("<ol>");
for (i in names){
document.write("<li>" + name_final[i] + "<br>");
}
document.write("</ol>");
</script>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<H2><center>HOwdy Hoe!</center></H2>
<h3>Here is a small list of names for no reason at all ??</h3>
<br>
<br>
<script LANGUAGE="javascript" type="text/javascript">
/* Variables */
names = new Array(10);
names_sorted = new Array(10);
proper_case = new Array();
names_split = new Array();
converter = new Array();
first_char = new Array();
rest_of_string = new Array();
names_compile = new Array();
names_final = new Array();
i = 0
/* End of Variables */
/* Main Loop */
do {
next = window.prompt("enter something BIATCH");
/* If there are any chars in "next" continue and assigne value to names[i] */
if (next > " ") names[i] = next;
/* Splits names[i] and assigns the value to names_split */
names_split[i] = names[i].split(" ");
/* Takes the strings and converts them to lower case and gives them to proper_case */
for (x = 0; x < (names_split.length + 1); x++){
proper_case[x] = names_split[x].toLowerCase();
}
for (y = 0; x < (proper_case.length + 1); y++) {
/* Gives the first character of each string to converter[y] */
converter[y] = proper_case[y].charAt(0);
/* Converts each first character to its upper case form */
first_char[y] = converter[y].toUpperCase();
/* gives the rest of the string to rest_of_string[y] */
rest_of_string[y] = proper_case[y].substring(1, proper_case[y].length);
}
for (z = 0; z < (first_char.length + 1); z++){
/* puts each split back together and gives them to names_compile */
names_compile[z]=(first_char[z] + rest_of_string[z]);
}
/* Joins the names back together */
names_final[i] = names_compile.join(" ");
i++;
}
while (next > " " && i > 10);
document.write("<h4>" + (names_final.length) + " names entered.</h4>");
document.write("<ol>");
for (i in names){
document.write("<li>" + name_final[i] + "<br>");
}
document.write("</ol>");
</script>
</body>
</html>