title: Check if checkboxes are selected on page load and add a class to parent html li
body: <p>Im looking a way to do it with prototype, this js, needs to loads with the page and interate over all the elements (inputs - checkboxes, in this case) with the given id and assign a class to its parent <code>&lt;li&gt;&lt;/li&gt;</code></p>
  
  <p>The JS is:</p>
  
  <pre><code>function changeSelectionStyle(id) {
  
   var inputId = id.substr(0,id.length-2);
   if(document.getElementById(inputId).checked){document.getElementById(id).className = 'yes';}
   alert(document.getElementById(inputId).checked);
  
   /*
    * if(document.getElementById(id).className != 'yes'){
    * document.getElementById(id).className = 'yes';
    *  } else{document.getElementById(id).className = '';}
    */
  
  }
  </code></pre>
  
  <p>And the HTML (piece of it) that interacts with this JS is:</p>
  
  <pre><code>&lt;li id="selectedAuthorities-4_1li"&gt;
     &lt;input type="checkbox" id="selectedAuthorities-4_1" name="selectedAuthorities" value="ROLE_ADD_COMMENT_TO_CV" checked="checked" onclick="changeSelectionStyle(this.id + 'li'); checkFatherSelection(this.id);"&gt;
         &lt;a href="#" onclick="document.getElementById('selectedAuthorities-4_1').click(); return false;"&gt;
             Agregar comentario
             &lt;samp&gt;&lt;b&gt;&lt;/b&gt;Permite agregar comentario en el detalle&lt;/samp&gt;
         &lt;/a&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>After iteration, checking is the checkbox is checked, it has to add  the <code>class="yes"</code> to the <code>&lt;li id="selectedAuthorities-4_1li"&gt;</code></p>