jQuery checkbox selection not working properly
<p>I have a form like this:</p>

<pre><code>&lt;form action='' onsubmit='void(0)' class="mainform"&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; One a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; two a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; Three a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; Four a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; Five a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; Six a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; Seven a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; eight a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; 9 a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; 10 a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; 11 a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; 12 a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; 13 a fancy cross-browser styled checkbox&lt;/label&gt;
                &lt;label class="form3"&gt;&lt;input type="checkbox"&gt; 14 a fancy cross-browser styled checkbox&lt;/label&gt;
&lt;/form&gt;
</code></pre>

<p>Now, I want to do this.
When i check and uncheck the boxes, I am updating the array 'checklist'.
If the box is checked, I set the corresponding array value to "yes", when unchecked, I set it to blank.</p>

<p>The problem now is, the setting of values only works once, if I uncheck a checked box and again check it, its value remains unchecked,</p>

<p>I am trying to do it like this:</p>

<pre><code>$(document).ready(function(){
$('.form3').each(function(i,e) {
   if(checklist[i] == "")
    {
        $(this).find('input[type=checkbox]').attr('checked', false);
        $(this).appendTo($('form'));
        $(this).find('input[type=checkbox]').change(function() {
            checklist[i]= "yes";
            $(this).closest('label').toggleClass("checkselected", this.checked);
        });
        $(this).closest('label').removeClass("checkselected");

    }
    else
    {
        $(this).find('input[type=checkbox]').attr('checked', true);
        $(this).find('input[type=checkbox]').change(function() {
            checklist[i]= "";
            $(this).closest('label').toggleClass("checkselected", this.checked);
        });
        $(this).closest('label').addClass("checkselected");
    }
});
});
</code></pre>

<p>Now I know that this maynot be the right way to do it because I am doing this inside the <code>"$('.form3').each(function(i,e)"</code></p>

<p>How can I make it work even with mulltiple clicks to the same checkbox.</p>
