Okay, I have two files one is the HTML where the user inputs a name, and clicks Add. The add button calls on a JavaScript Function created that is suppose to put sort the names. Adding One or more names does not show in the textarea created. Below are the code of the two files...can anyone suggest why it is not working or tell me where I did something wrong?
HTML Code
JavaScript File called Sort_Array_Exam ple.js
HTML Code
Code:
<html> <head><title>Array Sorting<title> <script language="JavaScript" type="text/javascript" src="Sort_Array_Example.js"></script> </head> <body> <h1>Sorting Through Names</h1> <p>Enter two or more names and the Sort </br> Button will sort the names in the text area</p> <form name="the_form"> Name: <input type="text" name = "new_name" size = "30"> <input type = "button" name = "add_name" value = "Add" onClick = "SortNames();"> <br> <h2>Sorted Names</h2> <textarea cols = "80" rows = "20" name = "namesSorted"> The sorted names appear here. </textarea> </form> </body> </html>
Code:
var numberNames=0; var names = new Array(); function SortNames(){ thename=document.the_form.new_name.value; names[numberNames]=thename; numberNames++; names.sort(); document.theform.namesSorted.value = names.join("\n");}
Comment