I just made up the name "userFriendlyNames". A VERY quick and dirty on arrays is that they are one variable that can hold many pieces of data. If an array held the names of the seven dwarves, for example, you might have something like:
var dwarves = new Array("Happy","Sneezy","Bashful","Doc","Grumpy","Sleepy","Dopey"

;
Then, dwarves[0] would be the same as saying "Happy", dwarves[1] would be the same as "Sneezy" ... and dwarves[6] would be the same as "Dopey" (notice that arrays are zero-based, so an array of seven elements have index numbers of 0 through 6).
You could then make their names show up on the screen in order with this simple javascript:
Code:
for(i=0;i<dwarves.length;i++)
alert(dwarves[i]);
In this case, dwarves.length is automatically equal to 7 because dwarves has seven elements.
There's more, but that'll get you started.
I was just supposing, that if your form was going to change over time, that you might consider using arrays as such:
Code:
<SCRIPT>
var fieldNames = new Array("namo", "surnamo", "cito", "stato", "zippo", "groucho");
var userFriendlyNames = new Array("name", "surname", "city", "state", "zip code", "favorite Marx Brother");
function validate()
{
var message = "";
for(i=0; i<fieldNames.length; i++)
{
if(form1.fieldNames[i].value == "")
message += "Please enter a " + userFriendlyNames[i] + " before continuing.\n";
}
if(message != "")
{
alert(message);
return false;
}
}
</SCRIPT>
Now, if you wanted to, for example, add a pet's name field to your form as such:
Code:
Pet's Name: <input type=text name=petto size=20><BR>
...then, you wouldn't have to add a whole additional if-statement to the validate code, you need merely update your arrays in the javascript as such:
Code:
var fieldNames = new Array("namo", "surnamo", "cito", "stato", "zippo", "groucho", "petto");
var userFriendlyNames = new Array("name", "surname", "city", "state", "zip code", "favorite Marx Brother", "favorite pet's name");
Notice that all I did was add an additional value in the list of parameters in each array.
'hope this answers your questions.
--Dave