title: Store checked checkbox value in javascript
body: <p>MY each div contain multiple checkbox and I have such several div . iwant to keep a track of which checkbox selected and their respective div . I am trying to store it inside a multidimensional array but it's not proper .. 
  If you have any other idea then plz share with me.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;style type="text/css" &gt;
  div{
  width:50%;
  height:500px; 
  border:2px solid black;
   }
  
  &lt;/style&gt;
  &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
  var count = 0;
   function selectradiobutn(frmname){
    formfield=document.forms[frmname].first_ques;
    for(i=0;i&lt;formfield.length;i++){
    if(formfield[i].checked==true){
    var value1 = formfield[i].value;
    alert(value1);
    var value = new Array;
    value[i]=value1;
    var myarray = new Array("A. Aluminium","B. Commodities that is               available according      to their demand","C. to remove salts","D.   1970 in Bangkok","D.    None of the above");
      if(myarray[i]==value[i]){
      count++;
      //alert(count);
      }
      }
      }
      return count;
        }
        function create_array1(){
        alert("Your score is"+count);
         document.getElementById('main').innerHTML = "Your score is"+count;
        }
  
  
        &lt;/script&gt;
        &lt;/head&gt;
          &lt;body&gt;
            &lt;div id="main" style="width:50%; height:500px; border:2px solid black;"&gt;
        &lt;center&gt;&lt;p style="padding:70px;"&gt;&lt;h1&gt;Click the button to start test&lt;/h1&gt;&lt;/p&gt;
           &lt;input type="button" value="Start test." id="btn_start"                 onclick="show_div('main','first1')"&gt; 
           &lt;/div&gt;
          &lt;/center&gt;
  
          &lt;div id="first1" style="display:none; "&gt;
  
              &lt;p style="padding:50px;"&gt;1.     For galvanizing iron which of the following metals is used ?
         &lt;/br&gt;
             &lt;form name="f1"&gt;
             &lt;input type=Checkbox name=first_ques  value="A. Aluminium"               onclick="selectradiobutn('f1')"&gt;A. Aluminium &lt;/br&gt;&lt;/br&gt;
              &lt;input type=Checkbox name=first_ques  value="B. Copper" onclick="selectradiobutn('f1')"&gt;B. Copper&lt;/br&gt;&lt;/br&gt;
            &lt;input type=Checkbox name=first_ques  value="C. Lead" onclick="selectradiobutn('f1')"&gt;C. Lead&lt;/br&gt;&lt;/br&gt;
              &lt;input type=Checkbox name=first_ques  value="D. Zinc" onclick="selectradiobutn('f1')"&gt;D. Zinc&lt;/br&gt;&lt;/p&gt;
              &lt;center&gt;&lt;input type="button"  value="Next" onclick="show_div('first1','first2')"&gt;&lt;/center&gt;
  </code></pre>
  
  <p>
  </p>
  
  <pre><code>              &lt;div id="first2"  style="display:none;"&gt;  
                &lt;p style="padding:50px;"&gt; 2. Economic goods are &lt;/br&gt;
               &lt;form name=f2&gt;
                    &lt;input type="Checkbox" name=first_ques value="first" onclick="selectradiobutn('f2')"&gt;A. all commodities that are limited in quantity as compared to their demand&lt;/br&gt;&lt;/br&gt;
                  &lt;input type="Checkbox" name=first_ques value="B. Commodities that is available according to their demand" onclick="selectradiobutn('f2')"&gt;B. Commodities that is available according to their demand&lt;/br&gt;&lt;/br&gt;
              &lt;input type="Checkbox" name=first_ques value="C. Commodities that is available more as compared to demand" onclick="selectradiobutn('f2')"&gt;C. Commodities that is available more as compared to demand&lt;/br&gt;&lt;/br&gt;
                &lt;input type="Checkbox" name=first_ques value="D. None of the above" onclick="selectradiobutn('f2')"&gt;D. None of the above&lt;/br&gt;&lt;/br&gt;&lt;/p&gt;
                  &lt;center&gt;&lt;input type="button"  value="Next" onclick="show_div('first2','first3')"&gt;&lt;/center&gt;
  </code></pre>
  
  <p>
  </p>
  
  <pre><code>      &lt;div id="first3" style="display:none;"&gt;   
           &lt;p style="padding:50px;"&gt;3. For purifying drinking water alum is used
               &lt;form name="f3"&gt;
                &lt;input type="Checkbox" value="A. for coagulation of mud particles" name=first_ques onclick="selectradiobutn('f3')"&gt;A. for coagulation of mud particles&lt;/br&gt;                 &lt;/br&gt;
          &lt;input type="Checkbox" value="B. to kill bacteria" name=first_ques onclick="selectradiobutn('f3')"&gt;B. to kill bacteria&lt;/br&gt;&lt;/br&gt;
           &lt;input type="Checkbox" value="C. to remove salts" name=first_ques onclick="selectradiobutn('f3')"&gt;C. to remove salts&lt;/br&gt;&lt;/br&gt;
         &lt;input type="Checkbox" value="D. to remove gases" name=first_ques onclick="selectradiobutn('f3')"&gt;D. to remove gases&lt;/br&gt;&lt;/br&gt;&lt;/p&gt;
            &lt;center&gt;&lt;input type="button"  value="Next" onclick="show_div('first3','first4')"&gt;&lt;/center&gt;
                  &lt;/form&gt;
                   &lt;/div&gt;
  
  
  
          &lt;div id="first4" style="display:none;"&gt;     
              &lt;p style="padding:50px;"&gt;4. Hockey was introduced in the Asian Games in
               &lt;form name="f4"&gt;
             &lt;input type="Checkbox" value="A.     1958 in Tokyo" name=first_ques value="first_forth" onclick="selectradiobutn('f4')"&gt;A.   1958 in Tokyo&lt;/br&gt;&lt;/br&gt;
             &lt;input type="Checkbox" value="B.     1962 in Jakarta"  name=first_ques onclick="selectradiobutn('f4')"&gt;B.    1962 in Jakarta&lt;/br&gt;&lt;/br&gt;
            &lt;input type="Checkbox" value="B.  1962 in Jakarta"  name=first_ques onclick="selectradiobutn('f4')"&gt;B.    1962 in Jakarta&lt;/br&gt;&lt;/br&gt;
              &lt;input type="Checkbox" value="D.    1970 in Bangkok" name=first_ques onclick="selectradiobutn('f4')"&gt;D.     1970 in Bangkok&lt;/br&gt;&lt;/br&gt;&lt;/p&gt;
         &lt;center&gt;&lt;input type="button"  value="Next" onclick="show_div('first4','first5')"&gt;&lt;/center&gt;
  
           &lt;/form&gt;
               &lt;/div&gt;
  
  
  
               &lt;div  id="first5" style="display:none;"&gt;   
                 &lt;p style="padding:50px;"&gt;5.ESCAP stands for
                   &lt;form name="f5"&gt;
                      &lt;input type="Checkbox" value="A.    Economic and Social Commission for Asia and Pacific" name=first_ques onclick="selectradiobutn('f5')"&gt;A.     Economic and Social Commission for Asia and Pacific&lt;/br&gt;&lt;/br&gt;
                   &lt;input type="Checkbox" value="B.   European Society Council for Africa and Pacific" name=first_ques onclick="selectradiobutn('f5')"&gt;B.     European Society Council for Africa and Pacific&lt;/br&gt;&lt;/br&gt;
                &lt;input type="Checkbox" value="C.  Economic and Social Commission for Africa and Pacific" name=first_ques onclick="selectradiobutn('f5')"&gt;C.   Economic and Social Commission for Africa and Pacific&lt;/br&gt;&lt;/br&gt;
                &lt;input type="Checkbox" value="D.  None of the above"  name=first_ques onclick="selectradiobutn('f5')"&gt;D.  None of the above&lt;/br&gt;&lt;/br&gt;&lt;/p&gt;
  </code></pre>
  
  <p> 
                   
               
             
                  </p>