title: HTML Input Array: How to get html input array values with javascript
body: <p>I have this code which works fine!:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script&gt;
  function get(userfirstname, userlastname){
   alert(userfirstname);
  
   return false;
  }
  &lt;/script&gt;
  
  &lt;form action="" method="POST"&gt;
      &lt;input type="text" name="userfirstname"&gt;
      &lt;input type="text" name="userlastname"&gt;
      &lt;input type="submit" onclick="return get(userfirstname.value, userlastname.value);"&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>i am trying to catch the input values with an array like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script&gt;
  function get(user){
   alert(user["firstname"].value);
  
   return false;
  }
  &lt;/script&gt;
  
  &lt;form action="" method="POST"&gt;
      &lt;input type="text" name="user[firstname]"&gt;
      &lt;input type="text" name="user[lastname]"&gt;
      &lt;input type="submit" onclick="return get(user);"&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>i tried so many different scenarios, no point :(</p>
  
  <p>Any hint would be appreciated.</p>