jQuery looping through multiple forms
<p>I have some forms which are creating dynamically and I have a common submit button, on that click, I need to loop through all forms and get the value of one particular element and need to get the sum. I have given some sample code below, the problem is, the code is executing 4 times, but Im expecting the loop should execute 2 times. what is wrong with this code ?</p>

<pre><code>    &lt;html&gt;
        &lt;head&gt;
          &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
            &lt;script&gt;
            $("document").ready(function() {
                $('form').each(function(index) {
                    $('form &gt; select').each(function(selindex) {
                        alert(index + ":"+ selindex + ': ' + $(this).text());
                    });
                });
            });
            &lt;/script&gt;
        &lt;/head&gt;
    &lt;body&gt;
        &lt;form name="form[1]"&gt;
            &lt;input type="text"&gt;
            &lt;select name="select[1]"&gt;
                &lt;option value="1"&gt;One 1&lt;/option&gt;
                &lt;option value="2"&gt;Two 1&lt;/option&gt;
            &lt;/select&gt;
        &lt;/form&gt;
        &lt;form name="form[2]"&gt;
            &lt;select name="select[2]"&gt;
                &lt;option value="1"&gt;One 2&lt;/option&gt;
                &lt;option value="2"&gt;Two 2&lt;/option&gt;
            &lt;/select&gt;
        &lt;/form&gt;
    &lt;/body&gt;
    &lt;/html&gt;
</code></pre>
