jQuery - Trying to come up with a good strategy
<p>I have some very old hand coded JavaScript which is not scalable. There are loops and loops inside of each other. So I am trying to figure out how to upgrade it into jQuery.</p>

<p>Here is how it works:</p>

<ul>
<li><p>PHP outputs 2 things - a checkbox and a drop down select box (in some cases 2 drop downs)</p></li>
<li><p>The count of checkbox and selectboxes varies. Sometimes there is only 1 and sometimes there are 5 or 7 or 10. </p></li>
</ul>

<p>Here is how the javascript works:</p>

<ol>
<li><p>If a user selects something from the dropdown or 2 drop downs and clicks on Submit, then the checkbox next to it is automatically checked before submitting the form.</p></li>
<li><p>If a user selects the checkbox but the dropdown is not selected or the default (first value) is selected, then it calls the validation plugin. </p></li>
<li><p>If a user selects the check and selects only one of 2 dropdowns, then it calls the validation.</p></li>
</ol>

<p>I have been able to figure out how to count the checkboxes in a div like this:</p>

<pre><code>total = 0;
$("#branches_checkboxes input[type=checkbox]").each(function () {
    total++;
}
</code></pre>

<p>The checkbox usually have a name such as <code>optionadd_id[2]</code> or <code>optionadd_id[3]</code> or <code>optionadd_id[4]</code></p>

<p>And the dropdown next to them have the name, respectively, <code>optionsselectid[2][2]</code> or <code>optionsselectid[3][2]</code> or <code>optionsselectid[4][2]</code></p>

<p>I am not looking for someone to code the entire thing for me. I just need some guidance on how to get started on this.</p>

<p>Thanks!</p>
