title: Add an onclick listener with an existing function using javascript
body: <p>I have an existing javascript function:</p>
  
  <pre><code>function changeColor(ID){
  
      try{
          initialize();
      }
      finally{
          changeDesign(ID);
      }
  
  }
  </code></pre>
  
  <p>I want to do something like this:</p>
  
  <pre><code>for(var x=0; x&lt;2; x++){
          document.getElementById(x).onclick = "changeColor(" + x +")";
  }
  </code></pre>
  
  <p>The output with the html should be:</p>
  
  <pre><code>&lt;tr bgcolor="#FFFFFF" id="0" onclick="changeColor(0)&gt;
  </code></pre>