title: How to use an array together with jQuery.val
body: <p>I want to have multiple form fields on a page and put the results into an array and then get them to the database. I had that and it worked.
  Then I put in an autocomplete function which gets its suggestions from the database. That works too but not if I try to use an array with it.</p>
  
  <pre><code>&lt;input type="text" name="PMS" id="PMS" autocomplete="off" onkeyup="autocomplete2()"&gt;
      &lt;input type="submit" name="submit" value="Lägg till"&gt;
  </code></pre>
  
  <p>The above and below provide working autocomplete functionality</p>
  
  <pre><code>function autocomplete2() {
  var keyword = $('#PMS').val();
  
  $.ajax({
      url: 'ajax_refresh.php',
      type: 'POST',
      data: {keyword:keyword},
      success:function(data){                  
  
          $('#Sökord_list').show();
          $('#Sökord_list').html(data);                              
      }
  }); }
  </code></pre>
  
  <p>However, if I try something like </p>
  
  <pre><code>&lt;input type="text" name="PMS[]" id="PMS[]" autocomplete="off" onkeyup="autocomplete2()"&gt;
  &lt;input type="submit" name="submit" value="Lägg till"&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>function autocomplete2() {
  var keyword = $('#PMS[]').val();
  
  $.ajax({
      url: 'ajax_refresh.php',
      type: 'POST',
      data: {keyword:keyword},
      success:function(data){
  
  
  
          $('#Sökord_list').show();
          $('#Sökord_list').html(data);
  
      }
  }); }
  </code></pre>
  
  <p>Again this might very well have something to do with my still lacking understanding of some of the basic principles of programming. Would really appreciate some help! Please tell me if you need more of the code.</p>