title: Pushing a button programmatically to submit a form on another page in Javascript
body: <p>Please forgive the basic question, I'm very new to Javascript and web development in general. I want to use a script on one page of my site to programmaticaly press a button to submit a form on another part of the site, making a <code>POST</code> request. The <code>html</code> I have to access is the following:</p>
  
  <p><strong>html</strong></p>
  
  <pre><code>&lt;form action="thing.jsp" method="post"&gt; // Beginning of form
  ...
  &lt;input type="submit" id="submit" value="Do something"&gt; // Button code
  ...
  &lt;/form&gt;
  </code></pre>
  
  <p>And I think the <code>Javascript</code> should look something like this:</p>
  
  <p><strong>JS</strong></p>
  
  <pre><code>   &lt;script&gt;
  
         var xhr = new XMLHttpRequest();
         xhr.open('POST', "/stuff.jsp", true);
         var params = "???????"; // What do I need to put here?
         xhr.send(params);
  
      &lt;/script&gt;
  </code></pre>
  
  <p>From reading around online, my suspicion is that I may just need to get the right value for <code>params</code>? Though if there's another way of achieving the same result (e.g. by just sending a <code>POST</code> request without doing anything to the button), I'd be perfectly happy to go with that.</p>
  
  <p>Thanks in advance for your time and wisdom.</p>