Input outside form are selected
<p>I have a little problem. I think I make a big noob mistake but I can't find it. In the following code I try to get input of my form, but it gets input outside of form too. Why is that ?</p>

<p>Here my JS code :</p>

<pre><code>function selectAll(bool){
    var form = document.forms['selectMailing'];
    for(var i=1; i&lt;=form.length; i++) {
        form.elements['select'+i].checked = bool;
    }
}
</code></pre>

<p>And HTML :</p>

<pre><code>&lt;input type=button value="Select All" onclick="selectAll(true)"/&gt;
&lt;form method=post action="" id="selectMailing" onsubmit="return checkSelect()"&gt;
    &lt;input type=checkbox name="select1" value="1" /&gt;
    &lt;input type=checkbox name="select2" value="1" /&gt;
    &lt;input type=submit value="Spammer" /&gt;
&lt;/form&gt;
</code></pre>

<p>So when i try this, JS return error 'Cannot set property 'checked' of undefined' on line where there is my input button. Why this stuff happens ? I select form and only his elements and input button has no name which can be confused with the name form.</p>

<p>Thanks for your help !</p>

<p>I know about jquery but I want to learn JavaScript before, so if your only anwser is 'use jQuery', please go help someone else :)</p>
