title: Making checkboxes checked using same id using Javascript
body: <p>This is my code to make check boxes checked with same id</p>
  
  <pre><code>&lt;input type="checkbox" name="MassApprove" value="setuju2"  /&gt;
  &lt;input type="checkbox" name="MassApprove" value="setuju3"  /&gt;
  &lt;input type="checkbox" name="MassApprove" value="setuju4"  /&gt;
  &lt;input type="checkbox" name="MassApprove" value="setuju5"  /&gt;
  &lt;input type="submit" value="Next Step" name="next" /&gt;
  </code></pre>
  
  <p>And This is my javascript code. I need to make this checkboxes as checked when am trigger this function. Help me!..</p>
  
  <pre><code>    function doMassApprove(massApproveFlag) {
          var confirmAlert = confirm("Do You Need Mass Approve !..");
          var massApprove = document.getElementById("MassApprove").length();
          if (confirmAlert == true) {
              //alert(massApproveFlag);
              for (var i = 0; i &lt; massApprove; i++) {
                  document.getElementById("MassApprove").checked = true;
              }
          } else {
              document.getElementById("headerMassApprove").checked = false;
          }
      }
  </code></pre>