Detect if a checkbox is checked, then get div id
<p>I have checkboxes on a page, when you click a span for each checkbox, it will change the background color of the containing div for each checkbox. The problem is when someone submits the form and goes to the following page, then clicks the back button the checkboxes remain checked but the div color reverts. Is there a way to get the div ids of checked boxes when the page loads?</p>

<p>I have this to detect checked boxes in by body onload, but not sure how to get div id for each of them:</p>

<pre><code>function detectchecked(){
  var count = 0;
  var inputs = myform.getElementsByTagName('input');
  for (var i = 0, j = inputs.length; i&lt;j; i++) {
      var input = inputs[i];
      if (input.type &amp;&amp; input.type === 'checkbox' &amp;&amp; input.checked) {
          alert(input);
      }
   }
  }
</code></pre>

<p>My current code for the inputs looks like this:</p>

<pre><code>&lt;div id="myform"&gt;
 &lt;div id="div4452101" style="float:left; width:194px; height:90px; border:1px solid #000; margin:2px;"&gt; 
  &lt;div class="resultphoto"&gt; 
   &lt;span onClick="checkem('4452101');"&gt; 
    image goes here
   &lt;/span&gt;
  &lt;/div&gt; 
  &lt;span onClick="checkem('4452101');"&gt; 
   check this
  &lt;/span&gt; 
  &lt;input type="checkbox" name="numbers[]" id="4452101" value="4452101" /&gt; 
 &lt;/div&gt;
&lt;/div&gt;
</code></pre>
