title: How to get html form without form id
body: <p>i'm creating a system than get html form values and send it to API. I created a simple html form with javascript to get values to send, but i get form using form ID, is there any way to get form without id ? i'll creating this to work in website than have only one .</p>
  <p>index.html</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
      &lt;title&gt;Document&lt;/title&gt;
      &lt;script src=&quot;teste1.js&quot;&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id=&quot;myForm&quot;&gt;
          &lt;label for=&quot;myName&quot;&gt;Send me your name:&lt;/label&gt;
          &lt;input id=&quot;myName&quot; name=&quot;name&quot; value=&quot;John&quot;&gt;&lt;br&gt;
          &lt;label for=&quot;myEmail&quot;&gt;Send me your email:&lt;/label&gt;
          &lt;input id=&quot;myEmail&quot; name=&quot;email&quot; value=&quot;Exemplo@exemplo.com&quot;&gt;&lt;br&gt;
          &lt;input type=&quot;submit&quot; value=&quot;Send Me!&quot;&gt;
        &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>teste1.js</p>
  <pre><code>window.addEventListener( &quot;load&quot;, function () {
      function sendData() {
        const XHR = new XMLHttpRequest();
        const FD = new FormData( form );
  
        const data = {
  
          name: FD.get('name'),
          email: FD.get('email')
  
        }
  
        // Define what happens on successful data submission
        XHR.addEventListener( &quot;load&quot;, function(event) {
          alert(&quot;Success.&quot;);
        } );
  
        // Define what happens in case of error
        XHR.addEventListener( &quot;error&quot;, function( event ) {
          //alert( 'Oops! Something went wrong.' );
        } );
  
        // Set up our request
        XHR.open( &quot;POST&quot;, &quot;API_URL&quot; );
        XHR.setRequestHeader('Content-type', 'application/json')
        // The data sent is what the user provided in the form
        XHR.send(JSON.stringify(data));
    }
   
    // Access the form element...
    const form = document.getElementById( &quot;myForm&quot; );
  
    // ...and take over its submit event.
    form.addEventListener( &quot;submit&quot;, function ( event ) {
      event.preventDefault();
  
      sendData();
    } );
  } );
  </code></pre>
  <p>look i get form with</p>
  <pre><code>const form = document.getElementById( &quot;myForm&quot; );
  </code></pre>
  <p>and</p>
  <pre><code>const FD = new FormData( form );
  </code></pre>
  <p>how get form without id, if it was like</p>
  <pre><code>&lt;form&gt;
  ...
  </code></pre>