title: Uncaught TypeError: Cannot read property '1' of undefined using value as array key
body: <p>I want to change the value of the input called <code>websitemod</code>, I want to put in it a value from <code>tab[var][1]</code>, where <code>var</code> is changed dynamycally depending on which option from the dropdown menu has been chosen. But, everytime I put <code>var val = $(this).val(); tab[val][1]</code>, I have an error (<code>Uncaught TypeError: Cannot read property '1' of undefined</code>), and when I do <code>var = 12; tab[val][1]</code>, it works. I assume the jQuery function I do to assign a value to <code>val</code> is not working. Do you have an idea ?</p>
  
  <p>The function itself :</p>
  
  <pre><code>$(document).ready(function () {
  
      // everytime the dropdown changes
      $('select[name=modservmenu]').change(function () {
          var val = $(this).val();
  
         // changes the value of the input
         $('input[name=websitemod]').val(tab[val][1]);
      });
  
  })
  </code></pre>
  
  <p>The tab, if you need it :</p>
  
  <pre><code>var tab = [
          ['10', ''],
          ['4', ''],
          ['8', ''],
          ['9', ''],
          ['11', ''],
          ['3', ''],
          ['2', ''],
          ['1', ''],
          ['6', ''],
          ['5', ''],
          ['7', ''],
          ['12', 'test.fr'],
          ];
  </code></pre>
  
  <p>EDIT :</p>
  
  <p>Changed the array as suggested in the comments, with the <code>parseInt</code> it does the thing I guess</p>
  
  <pre><code>var tab = {
       '10' : [''],
       '4' : [''],
       '8' : [''],
       '9' : [''],
       '11' : [''],
       '3' : [''],
       '2' : [''],
       '1' : [''],
       '6' : [''],
       '5' : [''],
       '7' : [''],
       '12' : ['test.fr'],
  };
  </code></pre>