title: How to use querySelectorAll and getAttribute?
body: <p>I have this HTML file ...</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
          &lt;title&gt;simple II&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
          &lt;div id="results"&gt;&lt;!-- Results are displayed here --&gt;
                  &lt;form method="post" name="start" target="_blank"&gt;
                          &lt;p&gt;Enter thing1: &lt;input type="text"     id="thing1" name="thing1" size="10" /&gt;&lt;/p&gt;
                          &lt;p&gt;Enter thing2: &lt;input type="text"     id="thing2" name="thing2" size="10" /&gt;&lt;/p&gt;
                          &lt;p&gt;Enter thing3: &lt;input type="text"     id="thing3" name="thing3" size="10" /&gt;&lt;/p&gt;
                          &lt;p&gt;Check thing4: &lt;input type="checkbox" id="thing4" name="thing4" value=1&gt;
                          &lt;input type="hidden" id="state" name="state" value="one" /&gt;&lt;/p&gt;
                  &lt;/form&gt;
                  &lt;button id='clickme' name='clickme'&gt;Click me&lt;/button&gt;
          &lt;/div&gt;
          &lt;script src="simple2.js?0000000000002"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>... and this javascript source file ...</p>
  
  <pre><code>document.querySelector("#results button").addEventListener("click", function(e) {
          e.preventDefault();
          var inputs = document.querySelectorAll("input");
          var params;
          var amp = "";
          for( var i = 0; i &lt; inputs.length; i++ ) {
                  var input       = inputs[i];
                  var name        = input.getAttribute(name);
                  var value       = input.getAttribute(value);
  
                  params +=       amp + name + "=" + value;
                  amp     =       "&amp;";
          }
          alert( params );
  });
  </code></pre>
  
  <p>... and when I fill out the form and click the button I get this result:</p>
  
  <p><img src="https://i.stack.imgur.com/Id27o.png" alt="enter image description here"></p>
  
  <p>Everthing is "null" :(
  What am I doing wrong here? </p>