<html>
<head>
</head>
<body>
<script type="text/javascript">
var arr = new Array();
var sortedARR = new Array();
// FORM to input the number of names
document.write("<form name=\"TEN\" method=\"\" action=\"\">");
document.write(" Please enter the numbers of names u want to input:<input type=\"text\" name=\"NoName\"> ");
var No = document.TEN.NoName.value;
var N;
N = eval(No);
document.write("<input type=\"button\" name=\"\" onclick=\"INPUT()\" value=\"Click for input!\" >");
document.write("</form>");
// FORM to input No of names
function INPUT()
{
document.write("<form name=\"TENDUOCNHAP\" method=\"\" action=\"\" >");
var i;
for(i=0; i<N; i++)
{
document.write("Name"+" "+i+":");
document.write("<input type=\"text\" name=\"input_name\" size=\"30px\" value=\" \" > <br/><br/>");
}
document.write("<input type=\"button\" name=\" \" onclick=\"SORT()\" value=\"Sortting!\" >");
document.write("</form>");
}
function SORT()
{
var i;
for(i=0; i<N; i++)
{
arr[i] = document.TENDUOCNHAP.input_name.value;
document.write(arr[i]);
}
sortedARR=arr.sort();
var x;
for (x in sortedARR)
document.write(sortedARR[x]);
}
</script>
</body>
</html>
I don't know why that does not work? I can not sorting the array!
Please help me! Thanks!