Cycling through an array of form elements
<p>I am returning form elements into a form from ajax.  I can count the number of elements returned, but I don't know how to cycle through them.  I need to be able to get the value of each element returned.</p>

<p>I am pretty sure this is a basic javascript thing that I just don't know.  The problem only looks more complicated with the Ajax.</p>

<p>My code looks like this:</p>

<pre><code>    // The view page
    &lt;html&gt;
    &lt;head&gt;
    &lt;script language="javascript"&gt;
    function calculateAlphaTotals(){
        var length = document.myForm["alpha[]"].length;
        alert( length ); // correctly outputs 3
        for( var i = 0; i &lt; length; i++ ){
            try{
                alert( document.myForm["alpha[]"].value ); // HTML ObjectCollection 
                alert( document.myForm["alpha["+i+"]"].value ); // Object Required
            } catch( error ) { }
        }
    }
    &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;form name="myForm" id="myFormId" method="post"&gt;
        &lt;div id="ajaxOutputId"&gt;&lt;/div&gt;
    &lt;/form&gt;
    &lt;/body&gt;
    &lt;/html&gt;

    // The Ajax page:

    &lt;input name="alpha[]" onchange="calculateAlphaTotals()" /&gt;
    &lt;input name="alpha[]" onchange="calculateAlphaTotals()" /&gt;
    &lt;input name="alpha[]" onchange="calculateAlphaTotals()" /&gt;
</code></pre>
