title: Make an array of input name attributes Javascript
body: <p>How can I make an array using a loop which contains the name attributes of inputs inside a form tag, using javascript.</p>
  
  <p>This is my code so far, but it doesn't seem to be working and I have looked at other similar questions to no avail.</p>
  
  <pre><code>      &lt;script type="text/javascript"&gt;
        var inputnames[];
        for (var i = 0; i &lt; document.getElementsByTagName('input').length; i++)
        {
        inputnames[document.getElementsByTagName("input")[i].name]
        };
        document.write(inputnames)
        &lt;/script&gt;
  </code></pre>