title: Javascript: On OnChange event passing array variable to another function
body: <p>In one JavaScript function, I am declaring an array variable <code>arr1</code>, and when user changes a dropdown value, <code>arr1</code> is passed to another function named <code>nat()</code>, which appends the value to that array.</p>
  
  <p>If the user selects another item from drop down, it should call this same function <code>nat()</code> and append that value to the same array.
  So <code>arr1[0] = 2</code> and <code>arr1[1] = 2</code></p>
  
  <p>Currently the problem is this: when I pass an array variable while selecting the dropdown, it's sending the array as a string to function <code>nat()</code>. I've tried all the different combinations. </p>
  
  <pre><code>function function1(){
  
  var table = document.getElementById("device1");
  new arr1=new Array();
  
  var row1 = table.insertRow(1);
  var cell1= row1.innerHTML = "&lt;select name='owner' id='ownerval' 
                               onChange=nat('"+arr1+"')&gt;&lt;option 
                               value='group'&gt;Select Group&lt;/option&gt;&lt;option 
                               value='FG'&gt;FG&lt;/option&gt;&lt;option 
                               value='PG'&gt;PG&lt;/option&gt;&lt;option
                               value='SG'&gt;SG&lt;/option&gt;&lt;/select&gt;";
  }
  function nat(arr1){
  arr1[arr1.length]=2;
  alert ("Value: "+ arr1[0]); 
  }
  </code></pre>
  
  <p>In alert <code>arr1[0]</code> is coming as "Undefined".</p>