title: Javascript: Change label background color on checkbox
body: <p>I am trying to change the background color of a label in each checkbox in a form based on the checked/unchecked state of the checkbox.So far I got it to change initially, but it won't change back when I uncheck:</p>
  
  <p><a href="http://jsfiddle.net/7wnCL/4/" rel="nofollow">http://jsfiddle.net/7wnCL/4/</a></p>
  
  <p>javascript:</p>
  
  <pre><code>function statecheck(layer) {
  var myLayer = document.getElementById(layer);
   if(myLayer.checked = true){
   myLayer.style.backgroundColor = "#bff0a1";
   } else {
   myLayer.style.backgroundColor = "#eee";
   };
  }
  </code></pre>
  
  <p>html:</p>
  
  <pre><code>&lt;form action="" method="get"&gt;
  &lt;label title="Alabama" id="Alabama"&gt;&lt;input type="checkbox" value="checkbox" onchange="statecheck('Alabama')" /&gt;AL&lt;/label&gt;
  &lt;label title="Alaska" id="Alaska"&gt;&lt;input type="checkbox" value="checkbox" onchange="statecheck('Alaska')" /&gt;AK&lt;/label&gt;
  &lt;label title="American Samoa" id="AmericanSamoa"&gt;&lt;input type="checkbox" value="checkbox" onchange="statecheck('AmericanSamoa')" /&gt;AS&lt;/label&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>css:</p>
  
  <pre><code>label {
  margin:0px 2px 4px 2px; 
  padding: 1px;
  background-color: #eee;
  display: block;
  width: 50px;
  }
  </code></pre>