title: Get ID or value of a checkbox onclick of that checkbox in pure Javascript
body: <p>I'm working on a script for my company that, upon clicking a checkbox:</p>
  
  <ul>
  <li>Fires function <code>OptionSelected()</code></li>
  <li>Gets <code>ID</code> of that checkbox</li>
  <li>Performs a bitwise operation based on that <code>ID</code></li>
  </ul>
  
  <p>Or, preferably:</p>
  
  <ul>
  <li>Fires function <code>OptionSelected()</code></li>
  <li>Fetches the integer assigned to that checkbox (<code>&lt;input="checkbox" value="2"</code>, get <code>2</code>)</li>
  <li>Performs bitwise operation with that <code>value</code>.</li>
  </ul>
  
  <p>To debug, I am having my code return to me an alert with the value inside. I've yet to write the bitwise operations portion.</p>
  
  <p>Here is my js code:</p>
  
  <pre><code>function OptionsSelected(e)
  {
      alert(e.target.id);
  }
  </code></pre>
  
  <p>And the example checkbox it references:</p>
  
  <pre><code>&lt;input type="checkbox" name="checkgrp" onclick="return OptionsSelected(e)" value="2" id="eXAMPLE"&gt;&lt;LABEL id="LeXAMPLE"&gt;&lt;/LABEL&gt;
  </code></pre>
  
  <p>When I click the box in runtime, I get this javascript error message:</p>
  
  <p><img src="https://i.stack.imgur.com/z7Saz.png" alt="enter image description here"></p>
  
  <p>Does anyone have a fix for this? I suppose it's rather simple, so in addition to supplying your fix, would you explain <em>why</em> your fix works? </p>
  
  <p>Bonus points if your solution saves me time by directly pulling the bitwise <code>value</code> in place of the actual <code>ID</code>.</p>
  
  <p>Note: I can't employ the <code>GetElementByID</code> method because I'll be <em>fetching</em> the <code>ID</code> or <code>value</code>, not using it to perform an action.</p>
  
  <p>Thanks, everyone!</p>