title: Javascript HTML checkbox array set onclick
body: <p>I have an array of check boxes, that I pass in to a function, with the intention of setting up a listener for each box.</p>
  
  <p>At this point all I want the listener to do is to display the id and the value of each checkbox in an alert box. Both attributes have been set before being passed into this function.</p>
  
  <p>The array is created and then passed through using the following line:</p>
  
  <pre><code>var oCustomMultiSelect = new customMultiSelect(oCheckBoxes);
  </code></pre>
  
  <p>The listeners are then activated using the following method:</p>
  
  <pre><code>function customMultiSelect(pCheckBoxes)
  {        
      for (i = 0; i &lt; pCheckBoxes.length; i++) {
          pCheckBoxListener(pCheckBoxes[i])
      }
  }
  </code></pre>
  
  <p>and this is the method that is supposed to set up the listeners:</p>
  
  <pre><code>function pCheckBoxListener(pCheckBox)
  {
      alert("Value " + pCheckBox.value + " ID " + pCheckBox.id);
  }
  </code></pre>
  
  <p>The method I have so far will display the correct values, but not onclick, it displays them at the time of construction. I want it to display them when they are clicked.</p>
  
  <p>I assume this is a very simple problem, but i cannot find the correct way to achieve this.</p>