title: Echo value of checkbox checked element in HTML form
body: <p>I've created an HTML form that has checkboxes that are checked dynamically due to a variable from a previous page (there is only one checkbox checked each time). </p>
  
  <p>What I'd like is to echo the value of this checkbox out (to make the main title of the page so javascript alert is not adapted).</p>
  
  <p>Example :</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
      &lt;h1&gt;Here I'd like to echo the value of the checkbox that is checked&lt;h1&gt;
      &lt;form id="myform" name="myform"&gt;
         &lt;p&gt;
         &lt;input type="checkbox" name="car" id="porsche" /&gt; &lt;label for="porsche"&gt;porsche&lt;/label&gt;&lt;br /&gt;
         &lt;input type="checkbox" name="car" id="ferrari" /&gt; &lt;label for="ferrari"&gt;ferrari&lt;/label&gt;&lt;br /&gt;
         &lt;/p&gt;
      &lt;script type="text/javascript"&gt;
  
      function loopForm(form,car) {
         var cbResults = 'Checkboxes: ';
         var radioResults = 'Radio buttons: ';
         for (var i = 0; i &lt; form.elements.length; i++ ) {
            if (form.elements[i].type == 'checkbox') {
               if (form.elements[i].id == car) {
                   form.elements[i].checked = true ;
               }
            }
          }
       }
       ...
       // This function will check one of the two checkboxes
       loopForm(document.myform,car);
       &lt;/script&gt;
       &lt;/body&gt;
       &lt;/html&gt;
  </code></pre>