jQuery - Able to disable checkboxes on condition, but odd problem
<p>I found some jQuery code as a result of a Google search that allowed me to disable specific classes of checkboxes based on user input of a single select box. I works great and I even added some code to grey out the text describing the text box. However, I use PHP (a session variable in particular) and MySQL to repopulate the select box' value if the user goes back/revisits the page and when that happens the checkboxes are no longer greyed out based on the value of the select box. I presume it's because the function requires the user to actually select an option, not for it to be the selected option on page load. Is there any way around this? See code below:</p>

<p><pre><code>
$(function(){
  var arrValPS = [ "3-Year-Old Program","Prekindergarten", "Kindergarten" ];</p>

<p>$("#grade").change(function(){
  var valToCheck = String($(this).val());</p>

<pre><code>if ( jQuery.inArray(valToCheck,arrValPS) == -1 )
{
</code></pre>

<p>$(".psc").attr("disabled", "true"); 
  jQuery('.pscdiv').fadeTo(500,0.2);</p>

<pre><code>}
else
{
        $(".psc").removeAttr ( "disabled" ); 
        jQuery('.pscdiv').fadeTo(500,1);   
}        
</code></pre>

<p>});
});
$(function(){
      var arrValLS = [ "1st Grade","2nd Grade","3rd Grade","4th Grade","5th Grade" ];</p>

<pre><code>  $("#grade").change(function(){
  var valToCheck = String($(this).val());

    if ( jQuery.inArray(valToCheck,arrValLS) == -1 )
    {
  $(".lsc").attr("disabled", "true"); 
  jQuery('.lscdiv').fadeTo(500,0.2);

    }
    else
    {
            $(".lsc").removeAttr ( "disabled" ); 
            jQuery('.lscdiv').fadeTo(500,1);   
    }        
  });
});
</code></pre>

<p>$(function(){
      var arrValMS = [ "6th Grade","7th Grade","8th Grade" ];</p>

<pre><code>  $("#grade").change(function(){
  var valToCheck = String($(this).val());

    if ( jQuery.inArray(valToCheck,arrValMS) == -1 )
    {
  $(".msc").attr("disabled", "true"); 
  jQuery('.mscdiv').fadeTo(500,0.2);

    }
    else
    {
            $(".msc").removeAttr ( "disabled" ); 
            jQuery('.mscdiv').fadeTo(500,1);   
    }        
  });
});
</code></pre>

<p></pre></code></p>

<p>An example of the checkboxes:</p>

<pre><code>&lt;div class="pscdiv"&gt;&lt;input type="checkbox" class="psc" name="camps[]" value="psc_1"/&gt;&lt;label for="psc_1"&gt;AM - Week 1: Description Here&lt;/label&gt;&lt;/div&gt;
&lt;div class="pscdiv"&gt;&lt;input type="checkbox" class="psc" name="camps[]" value="psc_2"/&gt;&lt;label for="psc_2"&gt;PM - Week 1: Description Here&lt;/label&gt;&lt;/div&gt;
&lt;div class="lscdiv"&gt;&lt;input type="checkbox" class="psc" name="camps[]" value="psc_3"/&gt;&lt;label for="lsc_1"&gt;AM - Week 2: Description Here&lt;/label&gt;&lt;/div&gt;
&lt;div class="lscdiv"&gt;&lt;input type="checkbox" class="psc" name="camps[]" value="psc_4"/&gt;&lt;label for="lsc_2"&gt;AM - Week 2: Description Here&lt;/label&gt;&lt;/div&gt;
&lt;div class="mscdiv"&gt;&lt;input type="checkbox" class="psc" name="camps[]" value="psc_5"/&gt;&lt;label for="msc_1"&gt;PM - Week 2: Description Here&lt;/label&gt;&lt;/div&gt;
&lt;div class="mscdiv"&gt;&lt;input type="checkbox" class="psc" name="camps[]" value="psc_6"/&gt;&lt;label for="msc_2"&gt;AM - Week 3: Description Here&lt;/label&gt;&lt;/div&gt;
</code></pre>

<hr>

<p>Update #1</p>

<p>I have tried Abdullah's code below with zero success. I have also tried the other suggestions with zero success. A couple people have said I could use less code basically, but everything I've tried hasn't worked whereas what I have now works perfectly except for the one nagging issue that I posted this question about. As much as I would like to thin it down it's way more important to me to get past the problem first. </p>
