title: Need to pass local array to a function on click
body: <p>I am writing a menu system and I need to call a function when the user clicks on a specific row. I am using new function to pass the div that called the function as well as the row the user clicked on. All well and good until I try to pass a local array to the function. If I do the following:</p>
  
  <pre><code>for (i=0;i&lt;tmpdropnumber;i++){
      var dv=document.getElementById(id+i);
      dv.style.cursor="pointer";  
      dv.onmouseover = new Function('dropover'+"('" + id + "','" + i + "')");
      dv.onmouseout = new Function('dropout'+"('" + id + "','" + i + "')");
      dv.onclick = new Function('dropclick'+"('" + id + "','" + i + "','"+tmparray1+"','"+tmparray2+"')");
  }
  </code></pre>
  
  <p>As you'd expect the arrays are passed as strings. I could rebuild the arrays in the function but that seems inelegant.</p>
  
  <p>if I try the following:</p>
  
  <pre><code>for (i=0;i&lt;tmpdropnumber;i++){
      var dv=document.getElementById(id+i);
      dv.style.cursor="pointer";  
      dv.onmouseover = new Function('dropover'+"('" + id + "','" + i + "')");
      dv.onmouseout = new Function('dropout'+"('" + id + "','" + i + "')");
      dv.onclick = new Function('dropclick'+"('" + id + "','" + i + "',"+tmparray1+","+tmparray2+")");
  }
  </code></pre>
  
  <p>Trying to pass the arrays it crashes. Any ideas on how I can achieve this? I am using jquery in my code so wither a javascript or jquery solution would be fine.</p>