jQuery dynamic event binding
<p>I think this is a pretty basic question, but I'm struggling with this problem.</p>

<p>On my form I have an option to dynamically add a new row to the table, which is simple enough to do with jQuery. On one of the elements, I need to bind an event, also relatively straightforward. The part I'm having problems with is the event that needs to be bound has to take a parameter. So, the code I've got:</p>

<pre><code>$(newrow).find("select").each(function () {
  var ochange = function(handle){
    var thisselect = "select" + handle;
    var thislink = "link" + handle;
    var thiscollate = "collate" + handle;
    if(document.getElementById(thisselect).value == 4){
     document.getElementById(thislink).style.visibility = 'visible';
    }
    else{
     document.getElementById(thislink).style.visibility = 'hidden';
     document.getElementById(thiscollate).value = "";
    }
  };
  $(this).change(ochange);
  $(this).attr("name", "select" + numfields);
  $(this).attr("id", "select" + numfields);
 });
</code></pre>

<p>The event binds as expected, but the "handle" variable doesn't register (of course because I'm pretty sure this is incorrect syntax). Also, this function that I want to bind to the dynamic form element is actually already defined, so if there is a way I can call an already-defined function (that takes a parameter) I'd love to hear about it.</p>
