title: how to return two functions for onclick event
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2568966/how-do-i-pass-the-value-not-the-reference-of-a-js-variable-to-a-function">How do I pass the value (not the reference) of a JS variable to a function?</a>  </p>
  </blockquote>
  
  
  
  <p>i have several links (var a[]) with an onclick event on them. this works well so far by using one function:</p>
  
  <pre><code>function setCurrentImage(x) {
      return function() {
          alert("Image: "+x);
          return false;
      }
  }
  
  for(var i = 0; i &lt; a.length; i++) {
      a[i].onclick = setCurrentImage(i);
  }
  </code></pre>
  
  <p>the thing is, i need two functions. and this code just won't work:</p>
  
  <pre><code>function setCurrentImage(x) {
      return function() {
          alert("Image: "+x);
      }
  }
  
  function setCurrentNote(x) {
      return function() {
          alert("Note: "+x);
      }
  }
  
  for(var i = 0; i &lt; a.length; i++) {
      a[i].onclick = function() {
          setCurrentImage(i);
          setCurrentNote(i);
          return false;
      }
  }
  </code></pre>
  
  <p>what is wrong with this code? thanks in advance :)</p>