title: limiting checkboxes to one html javascript
body: <p>I have a list of checkboxes which I want to limit 1 checkbox only being able to be selected, I found a piece of javascript that is suppose to do this but have not been able to impolement it successfully below is what I have tried without luck. </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;link type="text/css" rel="stylesheet" href="style.css" /&gt;
      &lt;script type="text/javascript"&gt;
          function control(j) {
              var total=0;
              for(var i=0; i &lt; document.form1.ckb.length; i++){
                  if(document.question.ckb[i].checked){
                      total =total +1;}
                  if(total &gt; 1){
                      alert("Please Select only one")
                      document.question.ckb[j].checked = false ;
                      return false;
                  }
              }
          } &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;header&gt;
  
  &lt;/header&gt;
  
  &lt;div id='wrapper'&gt;
  
  &lt;section id='description'&gt;
      &lt;p&gt;This quiz is compossed by 10 questions, you have to answer at least 7
          from 10 to pass the exam.&lt;/p&gt;
      &lt;h2&gt;Good luck!&lt;/h2&gt;
  &lt;/section&gt;
  
  &lt;div id='questions-number'&gt;
      &lt;p&gt;Question &lt;span id='current-question'&gt;1&lt;/span&gt; of &lt;span&gt;10&lt;/span&gt; &lt;/p&gt;
  &lt;/div&gt;
  
  &lt;section id='questions'&gt;
      &lt;p id='question'&gt;&lt;/p&gt;
  
      &lt;ul&gt;
          &lt;li&gt;&lt;input type='checkbox' id='checkAnswer0' name = ckb answer0 value=0 onclick=' control(0)'/&gt;&lt;label id='answer0'&gt;answer0&lt;/label&gt;&lt;/li&gt;
          &lt;li&gt;&lt;input type='checkbox' id='checkAnswer1' name = ckb answer0 value=1 onclick=' control(2)'/&gt;&lt;label id='answer1'&gt;answer0&lt;/label&gt;&lt;/li&gt;
          &lt;li&gt;&lt;input type='checkbox' id='checkAnswer2' name = ckb answer0 value=2 onclick=' control(3)'/&gt;&lt;label id='answer2'&gt;answer0&lt;/label&gt;&lt;/li&gt;
          &lt;li&gt;&lt;input type='checkbox' id='checkAnswer3' name = ckb answer0 value=4 onclick=' control(4)'/&gt;&lt;label id='answer3'&gt;answer0&lt;/label&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/section&gt;
  
  &lt;div id='next'&gt;
      next
  &lt;/div&gt;
  
  &lt;/div&gt;
  &lt;script type = "text/javascript" src="js/jquery-1.9.1.js"&gt;&lt;/script&gt;
  &lt;script type = "text/javascript" src= "js/question_script.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>