====== Initialize an Array ======
1) Initialize the array when the load event is fired.
var initArray = [];
function init() {
var fE = document.forms['testForm'].elements;
for(var i = 0; i < 4; i++) {
initArray[i] = fE['field' + (i + 1)];
}
}//
2) Store the field names and look them up in your functions
var initArray = ['field1', 'field2', 'field3', 'field4'];
function getValuesA() {
var v = ['One', 'Two', 'Three', 'Four'],
fE = document.forms['testForm'].elements;
for(var i = 0; i < 4; i++) {
fE[initArray[i]].value = v[i];
}
}
{{keywords>initialize array}}
~~DISCUSSION~~