How to pass some parameters to function called in addEventListener?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/256754/how-to-pass-arguments-to-addeventlistener-listener-function">How to pass arguments to addEventListener listener function?</a>  </p>
</blockquote>



<p>How can I pass some argument (in this case an integer) to a function through <code>addEventListener</code> on a <code>click</code> event?</p>

<p>I have two buttons; if I press the right one I want to do some stuff, if I press the left one then I'd like it to do something else.</p>

<p>Here's the code:</p>

<pre><code>document.getElementById('date_right').addEventListener( 'click', switch_date(1), false );
document.getElementById('date_left').addEventListener( 'click', switch_date(-1), false );
  function switch_date( k )
  {
    if(k==1)
    {
      //do stuff
    }
  else
  {
    //another stuff
  }
}
</code></pre>
